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

PPTX
Unit -1 CAP.pptx
PPTX
introduction to python
PPTX
Chapter7-Introduction to Python.pptx
PDF
Fundamentals of python
PPT
Python - Module 1.ppt
PDF
Python PPT1.pdf
ODP
An Intro to Python in 30 minutes
PPT
program on python what is python where it was started by whom started
Unit -1 CAP.pptx
introduction to python
Chapter7-Introduction to Python.pptx
Fundamentals of python
Python - Module 1.ppt
Python PPT1.pdf
An Intro to Python in 30 minutes
program on python what is python where it was started by whom started

Similar to Python (3).pdf (20)

PPT
Python Over View (Python for mobile app Devt)1.ppt
PPT
Py-Slides-1.ppt1234444444444444444444444444444444444444444
PPT
Python slides for the beginners to learn
PPTX
Introduction to Python Programming .pptx
PPT
Py-Slides-1.pptPy-Slides-1.pptPy-Slides-1.pptPy-Slides-1.ppt
PDF
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PDF
GE3151_PSPP_UNIT_2_Notes
PPTX
Python - An Introduction
PDF
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
PPT
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
PPTX
python presntation 2.pptx
PPTX
python introduction initial lecture unit1.pptx
PPTX
Python intro
PDF
Python Programing Bio computing,basic concepts lab,,
PDF
Introduction to python programming
PPTX
Introduction to Python Programming Language
PPTX
Pyhton problem solving introduction and examples
PPTX
Python (Data Analysis) cleaning and visualize
PPTX
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
PPTX
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
Python Over View (Python for mobile app Devt)1.ppt
Py-Slides-1.ppt1234444444444444444444444444444444444444444
Python slides for the beginners to learn
Introduction to Python Programming .pptx
Py-Slides-1.pptPy-Slides-1.pptPy-Slides-1.pptPy-Slides-1.ppt
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
GE3151_PSPP_UNIT_2_Notes
Python - An Introduction
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
python presntation 2.pptx
python introduction initial lecture unit1.pptx
Python intro
Python Programing Bio computing,basic concepts lab,,
Introduction to python programming
Introduction to Python Programming Language
Pyhton problem solving introduction and examples
Python (Data Analysis) cleaning and visualize
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
Ad

Recently uploaded (20)

PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PDF
Business Analytics and business intelligence.pdf
PPT
Quality review (1)_presentation of this 21
PPTX
Introduction to machine learning and Linear Models
PPT
ISS -ESG Data flows What is ESG and HowHow
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PDF
Clinical guidelines as a resource for EBP(1).pdf
PDF
.pdf is not working space design for the following data for the following dat...
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PPTX
Qualitative Qantitative and Mixed Methods.pptx
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PPTX
climate analysis of Dhaka ,Banglades.pptx
PDF
Mega Projects Data Mega Projects Data
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
Reliability_Chapter_ presentation 1221.5784
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
Business Analytics and business intelligence.pdf
Quality review (1)_presentation of this 21
Introduction to machine learning and Linear Models
ISS -ESG Data flows What is ESG and HowHow
IBA_Chapter_11_Slides_Final_Accessible.pptx
Clinical guidelines as a resource for EBP(1).pdf
.pdf is not working space design for the following data for the following dat...
Introduction-to-Cloud-ComputingFinal.pptx
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
STUDY DESIGN details- Lt Col Maksud (21).pptx
Qualitative Qantitative and Mixed Methods.pptx
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
climate analysis of Dhaka ,Banglades.pptx
Mega Projects Data Mega Projects Data
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
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