SlideShare a Scribd company logo
Python (3).pdf
A Programming language
GROUP MEMBERS :
MUHAMMAD SAMI ULLAH WARIS
(insta: @samiwaris02)
Table of contents :
INTRODUCTION
HISTORY
USES OF PYTHON
FEATURES OF PYTHON
PYTHON PROJECT FOR BEGINNERS
PYTHON PROGRAM
KEY CHANGES IN PYTHON
BASIC SYNTAX
VARIABLE
NUMBERS
STANDARD TYPE HIERARCHY
STRING
CONDITIONALS
FOR LOOP
FUNCTION
KEYWORDS
WHY PYTHON ?
DIFFERENTIATE
EXAMPLES
• Python is an open-source (free) programming language
that is used in web programming, data science, artificial
intelligence, and many scientific applications. Learning
Python allows the programmer to focus on solving problems,
rather than focusing on syntax.
• Python is a computer programming language often
used to build websites and software, automate tasks,
and conduct data analysis. Python is a general-purpose
language, meaning it can be used to create a variety of
different programs and isn't specialized for any specific
problems.
1.
2.
3.
4.
5.
6.
PARADIGM :
DESIGNED BY :
DEVELOPER :
FIRST APPEAR :
STABLE RELEASE :
PREVIEW RELEASE :
7. TYPING DISCIPLINE :
Multi paradigm : object oriented ,
procedural , functional ,
structured, reflective
Guido Van Rassum
Python Software Foundation
February 20, 1991 (31 years ago)
3.10.5 June 6, 2022 (21 days ago)
3.11.0b3 June 1, 2022 (26 days ago)
Duck, dynamic, strong typing;[5] gradual
(since 3.5, but ignored in CPython)[6]
USES OF PHYTHON :
•
•
•
•
•
•
•
•
•
•
•
AI and machine learning. ...
Data analytics. ...
Data visualisation. ...
Programming applications. ...
Web development. ...
Game development. ...
Language development. ...
Finance …
SEO …
Design …
FEATURES
OF
PYTHON
FREE
EASY TO LEARN
READABLE
CROSS
PLATFORMS
OPEN
SOURCE
MEMORY
MANAGEMENT
FREE
LARGE STANDARD
LIBRARY
Python Project For Beginners :
So, if you were wondering what to do with Python and who uses
Python, we’ve given plenty of ideas for how it’s used.
Below, we’ve outlined some Python project ideas for beginners.
These can help you develop your knowledge and challenge your
abilities with the programming language: 
Build a guessing game 
Design a text-based adventure game 
Create a simple Python calculator
Write a simple, interactive quiz 
Build an alarm clock 
Once you’ve mastered the basics of Python, each of these can
challenge you and help you hone the skills you’ve already learned. 
Python Program :
• Thus, the same .py file can be a program/script, or a
module
• This feature is often used to provide regression tests
for modules
• When module is executed as a program, the
regression test is executed
• When module is imported, test functionality is not
executed
Key Changes In Python:
Python 2's print statement has been replaced by the print()
function.
There is only one integer type left, int.
Some methods such as map() and filter() return iterator
objects in Python 3 instead of lists in Python 2.
In Python 3, a TypeError is raised as warning if we try to
compare unorderable types. eg 1<0> None are no longer valid
Python 3 provides Unicode (utf-8) strings while Python 2 has
ASCII str() types and separate unicode().
A new built-in string formatting method format() replaces the 5
string formatting operator.
K
E
Y
C
H
A
N
G
E
S
Old : print Hello, world!! New: (Hello, World!")
Indentation is used in Python to delimit blocks. The number
of spaces is variable, but all statements within the same
block must be indented the same amount.
The header line for compound statements, such as if, while,
def, and class should be terminated with a colon (:)
The semicolon (;) is optional at the end of statement.
Printing to the Screen:
Reading Keyboard Input:
Comments
Single line:
Multiple lines:
Python files have extension .py
print ("Hello, Python!")
name = input ("Enter your name")
#This is a comment.
. . .
print("wo are in a comment")
print (we are still in a comment")
. . .
BASIC SYNTAX :
B
A
S
I
C
S
Y
N
T
A
X
VARIABLE :
.
Python is dynamically typed. You do not
need to declare variables!
The declaration happens automatically when you
assign a value to a variable.
Variables can change type, simply by assigning
them a new value of a different type.
Python allows you to assign a single value to
several variables simultaneously.
You can also assign multiple objects to
multiple variables.
counter = 100
miles = 85.6
name = ''John''
Z = None
# An Integer assignment
# A floating point
# A String
# A null string
x = 1
x = ''string value''
a = b = c = 1
a , b , c = 1, 2, ''John''
V
A
R
I
A
B
L
E
NUMBERS :
N
U
M
B
E
R
S :
THE STANDARD TYPE HIERARCHY
STRING :
name = ' sami topped in class '
name = '' saqib won match ''
name = ''''' najam 's birthday ''''
S
T
R
I
N
G
CONDITIONALS :
IF expression ;
statement ;
Syntax :
Syntax :
IF expression
statement ;
else
statement ;
IF expression
statement ;
else
statement ;
else
statement ;
else
statement ;
if statement :
if else.else..else.... statement : if else... statement :
CONDITIONALS :
if else statement program :
if else statement program :
.# If the number is positive, we print an appropriate message
num = 3
if num > 0:
print(num, "is a positive number.")
print("This is always printed.")
num = -1
if num > 0:
print(num, "is a positive number.")
print("This is also always printed.")
output :
output :
3 is a positive number
This is always printed
This is also always print
FOR LOOP :
Definition :
Definition :
syntax :
syntax :
for val in sequence:
loop body
• The for loop in Python is used to iterate over a
sequence (list, tuple, string) or other iterable
objects. Iterating over a sequence is called
traversal.
• Loop continues until we reach the last item in
the sequence. The body of for loop is separated
from the rest of the code using indentation.
FOR LOOP :
For Loop program :
For Loop program :
.# Program to find the sum of all numbers stored in a list
# List of numbers
numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11]
# variable to store the sum
sum = 0
# iterate over the list
for val in numbers:
sum = sum+val
print("The sum is", sum)
output :
output :
The sum is 48
FUNCTION :
Definition :
Definition :
syntax :
syntax :
def function_name(parameters):
"""docstring"""
statement(s)
•
•
•
In Python, a function is a group of related statements that
performs a specific task.
Functions help break our program into smaller and modular
chunks. As our program grows larger and larger, functions
make it more organized and manageable.
Furthermore, it avoids repetition and makes the code
reusable
Characteristics :
Characteristics :
Example :
Example :
def greet(name):
""'
This function greets to the person
passed in as a parameter
"""
print("Hello, " + name + ". Good morning!")
1.
2.
3.
4.
5.
6.
7.
Keyword def that marks the start of the function header.
A function name to uniquely identify the function. Function naming
follows the same rules of writing identifiers in Python.
Parameters (arguments) through which we pass values to a
function. They are optional.
A colon (:) to mark the end of the function header.
Optional documentation string (docstring) to describe what the
function does.
One or more valid python statements that make up the function
body. Statements must have the same indentation level (usually 4
spaces).
An optional return statement to return a value from the function.
KEYWORDS :
Python Keywords Rules :
Python Keywords Rules :
Examples :
Examples :
False await else import pass None
break except in raise True class
finally is return and continue for long
•
•
•
•
•
Keywords are the reserved words in Python.
We cannot use a keyword as a variable name, function
name or any other identifier. They are used to define the
syntax and structure of the Python language.
In Python, keywords are case sensitive.
There are 33 keywords in Python 3.7. This number can vary
slightly over the course of time.
All the keywords except True, False and None are in
lowercase and they must be written as they are. The list of
all the keywords is given below.
23
Why python ?
Extremely versatile language
Website development , data analysis….
Syntax is clear , easy to read & learn .
Common language .
Full modularity , hierarchical packages .
Comprehensive standard library for many tasks .
Big community .
Simply extendable via C/C++
Fast programming speeds
PYTHON VS JAVA :
Python :
Python :
•
•
•
•
•
•
•
•
•
•
Statically typed
Compiled
Platform-independent
Bigger community
More libraries and documentation
Larger legacy systems
Mainly used for web, mobile,
enterprise-level
Limited string related functions
Learning curve is more complex
Usually faster than Python
Slower development process
requiring more lines of code
•
•
•
•
•
•
•
•
•
•
•
Dynamically typed
Interpreted
Dependent on a platform
Smaller yet fast-growing community
Fewer libraries and documentation
Fewer legacy problems
Mainly used for data science, Al,
and ML
Lots of string related functions
Easier to learn and use • Fast but
usually slower than Java
Faster development process,
involves writing
fewer lines of code
Java :
Java :
25
PYTHON VS JAVA :
Welcome :
Welcome :
# Declaring variables
x, y = 12, 10
isTrue = True
greeting = "Welcome!"
Hello World :
Hello World :
public class Main {
public static void main(String[] args) {
// Declaring variables
int x = 12, y = 10;
boolean isTrue = true;
String greeting = "Welcome!"; } }
PYTHON :
JAVA :
print ( '' Hello World '' )
public class Main {
public static void main(String[] args) {
// To Hello World
system out , print in( '' Hello World" ; } }
PYTHON :
JAVA :
26
PROGRAM EXAMPLE :
To find largest number of two numbers :
To find largest number of two numbers :
Output :
Output :
# Finding largest of two numbers #
Reading numbers
first = float(input('Enter first number: '))
second = float(input('Enter second
number: '))
# Making decision and displaying
if first > second:
large = first
else:
large = second
print('Largest = %d' %(large))
Enter first number: 33
Enter second number:
23 Largest = 33
27
PROGRAM EXAMPLE :
Multiplication table of numbers :
Multiplication table of numbers :
Output :
Output :
# Multiplication table of 1 to 10
for i in range(1,11):
print("nnMULTIPLICATION TABLE FOR %dn" %(i))
for j in range(1,11):
print("%-5d X %5d = %5d" % (i, j, i*j )
MULTIPLICATION TABLE FOR 8
8 X 1 = 8
8 X 2 = 16
8 X 3 = 24
8 X 4 = 32
8 X 5 = 40
8 X 6 = 48
8 X 7 = 56
8 X 8 = 64
8 X 9 = 72
8 X 10 = 80
28
PROGRAM EXAMPLE :
1 22 333…. pattern numbers :
1 22 333…. pattern numbers :
Output :
Output :
# 1-22-333-4444 Pattern up to n lines
n = int(input("Enter number of rows: "))
for i in range(1,n+1):
for j in range(1, i+1):
print(i, end="")
print()
Enter number of rows: 8
1
22
333
4444
55555
666666
7777777
88888888
29
Python (3).pdf

More Related Content

Similar to Python (3).pdf (20)

PPTX
Python (Data Analysis) cleaning and visualize
IruolagbePius
 
PPTX
Python fundamentals
natnaelmamuye
 
PPTX
Introduction to Python Programming .pptx
NaynaSagarDahatonde
 
PDF
web programming UNIT VIII python by Bhavsingh Maloth
Bhavsingh Maloth
 
PDF
Tutorial on-python-programming
Chetan Giridhar
 
PDF
Python Programming
Saravanan T.M
 
PDF
Python for katana
kedar nath
 
PDF
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
AbdulmalikAhmadLawan2
 
PDF
Intro-to-Python-Part-1-first-part-edition.pdf
ssuser543728
 
PDF
Fundamentals of python
BijuAugustian
 
PPT
Introduction to python
Ranjith kumar
 
PPTX
INTRODUCTION TO PYTHON.pptx
Nimrahafzal1
 
PDF
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
PPTX
Python intro
Piyush rai
 
PDF
Python Interview Questions PDF By ScholarHat.pdf
Scholarhat
 
PPTX
Pyhton problem solving introduction and examples
ssuser65733f
 
PDF
Python basics_ part1
Elaf A.Saeed
 
PDF
Python and Pytorch tutorial and walkthrough
gabriellekuruvilla
 
PPTX
UNIT 1 .pptx
Prachi Gawande
 
PDF
Python Module-1.1.pdf
4HG19EC010HARSHITHAH
 
Python (Data Analysis) cleaning and visualize
IruolagbePius
 
Python fundamentals
natnaelmamuye
 
Introduction to Python Programming .pptx
NaynaSagarDahatonde
 
web programming UNIT VIII python by Bhavsingh Maloth
Bhavsingh Maloth
 
Tutorial on-python-programming
Chetan Giridhar
 
Python Programming
Saravanan T.M
 
Python for katana
kedar nath
 
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
AbdulmalikAhmadLawan2
 
Intro-to-Python-Part-1-first-part-edition.pdf
ssuser543728
 
Fundamentals of python
BijuAugustian
 
Introduction to python
Ranjith kumar
 
INTRODUCTION TO PYTHON.pptx
Nimrahafzal1
 
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
Python intro
Piyush rai
 
Python Interview Questions PDF By ScholarHat.pdf
Scholarhat
 
Pyhton problem solving introduction and examples
ssuser65733f
 
Python basics_ part1
Elaf A.Saeed
 
Python and Pytorch tutorial and walkthrough
gabriellekuruvilla
 
UNIT 1 .pptx
Prachi Gawande
 
Python Module-1.1.pdf
4HG19EC010HARSHITHAH
 

Recently uploaded (20)

PPTX
Advanced_NLP_with_Transformers_PPT_final 50.pptx
Shiwani Gupta
 
PPTX
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
PPTX
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
PDF
Research Methodology Overview Introduction
ayeshagul29594
 
PDF
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
PPTX
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
PPTX
Numbers of a nation: how we estimate population statistics | Accessible slides
Office for National Statistics
 
PDF
apidays Singapore 2025 - From API Intelligence to API Governance by Harsha Ch...
apidays
 
PPT
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
PDF
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
PDF
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
PDF
apidays Singapore 2025 - Streaming Lakehouse with Kafka, Flink and Iceberg by...
apidays
 
PDF
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
PDF
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
PDF
What does good look like - CRAP Brighton 8 July 2025
Jan Kierzyk
 
PDF
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
PPTX
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
PDF
apidays Singapore 2025 - The API Playbook for AI by Shin Wee Chuang (PAND AI)
apidays
 
PDF
Development and validation of the Japanese version of the Organizational Matt...
Yoga Tokuyoshi
 
Advanced_NLP_with_Transformers_PPT_final 50.pptx
Shiwani Gupta
 
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
Research Methodology Overview Introduction
ayeshagul29594
 
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
Numbers of a nation: how we estimate population statistics | Accessible slides
Office for National Statistics
 
apidays Singapore 2025 - From API Intelligence to API Governance by Harsha Ch...
apidays
 
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
apidays Singapore 2025 - Streaming Lakehouse with Kafka, Flink and Iceberg by...
apidays
 
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
What does good look like - CRAP Brighton 8 July 2025
Jan Kierzyk
 
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
apidays Singapore 2025 - The API Playbook for AI by Shin Wee Chuang (PAND AI)
apidays
 
Development and validation of the Japanese version of the Organizational Matt...
Yoga Tokuyoshi
 
Ad

Python (3).pdf

  • 3. GROUP MEMBERS : MUHAMMAD SAMI ULLAH WARIS (insta: @samiwaris02)
  • 4. Table of contents : INTRODUCTION HISTORY USES OF PYTHON FEATURES OF PYTHON PYTHON PROJECT FOR BEGINNERS PYTHON PROGRAM KEY CHANGES IN PYTHON BASIC SYNTAX VARIABLE NUMBERS STANDARD TYPE HIERARCHY STRING CONDITIONALS FOR LOOP FUNCTION KEYWORDS WHY PYTHON ? DIFFERENTIATE EXAMPLES
  • 5. • Python is an open-source (free) programming language that is used in web programming, data science, artificial intelligence, and many scientific applications. Learning Python allows the programmer to focus on solving problems, rather than focusing on syntax. • Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. Python is a general-purpose language, meaning it can be used to create a variety of different programs and isn't specialized for any specific problems.
  • 6. 1. 2. 3. 4. 5. 6. PARADIGM : DESIGNED BY : DEVELOPER : FIRST APPEAR : STABLE RELEASE : PREVIEW RELEASE : 7. TYPING DISCIPLINE : Multi paradigm : object oriented , procedural , functional , structured, reflective Guido Van Rassum Python Software Foundation February 20, 1991 (31 years ago) 3.10.5 June 6, 2022 (21 days ago) 3.11.0b3 June 1, 2022 (26 days ago) Duck, dynamic, strong typing;[5] gradual (since 3.5, but ignored in CPython)[6]
  • 7. USES OF PHYTHON : • • • • • • • • • • • AI and machine learning. ... Data analytics. ... Data visualisation. ... Programming applications. ... Web development. ... Game development. ... Language development. ... Finance … SEO … Design …
  • 9. Python Project For Beginners : So, if you were wondering what to do with Python and who uses Python, we’ve given plenty of ideas for how it’s used. Below, we’ve outlined some Python project ideas for beginners. These can help you develop your knowledge and challenge your abilities with the programming language:  Build a guessing game  Design a text-based adventure game  Create a simple Python calculator Write a simple, interactive quiz  Build an alarm clock  Once you’ve mastered the basics of Python, each of these can challenge you and help you hone the skills you’ve already learned. 
  • 10. Python Program : • Thus, the same .py file can be a program/script, or a module • This feature is often used to provide regression tests for modules • When module is executed as a program, the regression test is executed • When module is imported, test functionality is not executed
  • 11. Key Changes In Python: Python 2's print statement has been replaced by the print() function. There is only one integer type left, int. Some methods such as map() and filter() return iterator objects in Python 3 instead of lists in Python 2. In Python 3, a TypeError is raised as warning if we try to compare unorderable types. eg 1<0> None are no longer valid Python 3 provides Unicode (utf-8) strings while Python 2 has ASCII str() types and separate unicode(). A new built-in string formatting method format() replaces the 5 string formatting operator. K E Y C H A N G E S Old : print Hello, world!! New: (Hello, World!")
  • 12. Indentation is used in Python to delimit blocks. The number of spaces is variable, but all statements within the same block must be indented the same amount. The header line for compound statements, such as if, while, def, and class should be terminated with a colon (:) The semicolon (;) is optional at the end of statement. Printing to the Screen: Reading Keyboard Input: Comments Single line: Multiple lines: Python files have extension .py print ("Hello, Python!") name = input ("Enter your name") #This is a comment. . . . print("wo are in a comment") print (we are still in a comment") . . . BASIC SYNTAX : B A S I C S Y N T A X
  • 13. VARIABLE : . Python is dynamically typed. You do not need to declare variables! The declaration happens automatically when you assign a value to a variable. Variables can change type, simply by assigning them a new value of a different type. Python allows you to assign a single value to several variables simultaneously. You can also assign multiple objects to multiple variables. counter = 100 miles = 85.6 name = ''John'' Z = None # An Integer assignment # A floating point # A String # A null string x = 1 x = ''string value'' a = b = c = 1 a , b , c = 1, 2, ''John'' V A R I A B L E
  • 15. THE STANDARD TYPE HIERARCHY
  • 16. STRING : name = ' sami topped in class ' name = '' saqib won match '' name = ''''' najam 's birthday '''' S T R I N G
  • 17. CONDITIONALS : IF expression ; statement ; Syntax : Syntax : IF expression statement ; else statement ; IF expression statement ; else statement ; else statement ; else statement ; if statement : if else.else..else.... statement : if else... statement :
  • 18. CONDITIONALS : if else statement program : if else statement program : .# If the number is positive, we print an appropriate message num = 3 if num > 0: print(num, "is a positive number.") print("This is always printed.") num = -1 if num > 0: print(num, "is a positive number.") print("This is also always printed.") output : output : 3 is a positive number This is always printed This is also always print
  • 19. FOR LOOP : Definition : Definition : syntax : syntax : for val in sequence: loop body • The for loop in Python is used to iterate over a sequence (list, tuple, string) or other iterable objects. Iterating over a sequence is called traversal. • Loop continues until we reach the last item in the sequence. The body of for loop is separated from the rest of the code using indentation.
  • 20. FOR LOOP : For Loop program : For Loop program : .# Program to find the sum of all numbers stored in a list # List of numbers numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11] # variable to store the sum sum = 0 # iterate over the list for val in numbers: sum = sum+val print("The sum is", sum) output : output : The sum is 48
  • 21. FUNCTION : Definition : Definition : syntax : syntax : def function_name(parameters): """docstring""" statement(s) • • • In Python, a function is a group of related statements that performs a specific task. Functions help break our program into smaller and modular chunks. As our program grows larger and larger, functions make it more organized and manageable. Furthermore, it avoids repetition and makes the code reusable
  • 22. Characteristics : Characteristics : Example : Example : def greet(name): ""' This function greets to the person passed in as a parameter """ print("Hello, " + name + ". Good morning!") 1. 2. 3. 4. 5. 6. 7. Keyword def that marks the start of the function header. A function name to uniquely identify the function. Function naming follows the same rules of writing identifiers in Python. Parameters (arguments) through which we pass values to a function. They are optional. A colon (:) to mark the end of the function header. Optional documentation string (docstring) to describe what the function does. One or more valid python statements that make up the function body. Statements must have the same indentation level (usually 4 spaces). An optional return statement to return a value from the function.
  • 23. KEYWORDS : Python Keywords Rules : Python Keywords Rules : Examples : Examples : False await else import pass None break except in raise True class finally is return and continue for long • • • • • Keywords are the reserved words in Python. We cannot use a keyword as a variable name, function name or any other identifier. They are used to define the syntax and structure of the Python language. In Python, keywords are case sensitive. There are 33 keywords in Python 3.7. This number can vary slightly over the course of time. All the keywords except True, False and None are in lowercase and they must be written as they are. The list of all the keywords is given below. 23
  • 24. Why python ? Extremely versatile language Website development , data analysis…. Syntax is clear , easy to read & learn . Common language . Full modularity , hierarchical packages . Comprehensive standard library for many tasks . Big community . Simply extendable via C/C++ Fast programming speeds
  • 25. PYTHON VS JAVA : Python : Python : • • • • • • • • • • Statically typed Compiled Platform-independent Bigger community More libraries and documentation Larger legacy systems Mainly used for web, mobile, enterprise-level Limited string related functions Learning curve is more complex Usually faster than Python Slower development process requiring more lines of code • • • • • • • • • • • Dynamically typed Interpreted Dependent on a platform Smaller yet fast-growing community Fewer libraries and documentation Fewer legacy problems Mainly used for data science, Al, and ML Lots of string related functions Easier to learn and use • Fast but usually slower than Java Faster development process, involves writing fewer lines of code Java : Java : 25
  • 26. PYTHON VS JAVA : Welcome : Welcome : # Declaring variables x, y = 12, 10 isTrue = True greeting = "Welcome!" Hello World : Hello World : public class Main { public static void main(String[] args) { // Declaring variables int x = 12, y = 10; boolean isTrue = true; String greeting = "Welcome!"; } } PYTHON : JAVA : print ( '' Hello World '' ) public class Main { public static void main(String[] args) { // To Hello World system out , print in( '' Hello World" ; } } PYTHON : JAVA : 26
  • 27. PROGRAM EXAMPLE : To find largest number of two numbers : To find largest number of two numbers : Output : Output : # Finding largest of two numbers # Reading numbers first = float(input('Enter first number: ')) second = float(input('Enter second number: ')) # Making decision and displaying if first > second: large = first else: large = second print('Largest = %d' %(large)) Enter first number: 33 Enter second number: 23 Largest = 33 27
  • 28. PROGRAM EXAMPLE : Multiplication table of numbers : Multiplication table of numbers : Output : Output : # Multiplication table of 1 to 10 for i in range(1,11): print("nnMULTIPLICATION TABLE FOR %dn" %(i)) for j in range(1,11): print("%-5d X %5d = %5d" % (i, j, i*j ) MULTIPLICATION TABLE FOR 8 8 X 1 = 8 8 X 2 = 16 8 X 3 = 24 8 X 4 = 32 8 X 5 = 40 8 X 6 = 48 8 X 7 = 56 8 X 8 = 64 8 X 9 = 72 8 X 10 = 80 28
  • 29. PROGRAM EXAMPLE : 1 22 333…. pattern numbers : 1 22 333…. pattern numbers : Output : Output : # 1-22-333-4444 Pattern up to n lines n = int(input("Enter number of rows: ")) for i in range(1,n+1): for j in range(1, i+1): print(i, end="") print() Enter number of rows: 8 1 22 333 4444 55555 666666 7777777 88888888 29