SlideShare a Scribd company logo
Introduction to Programming Language
(Python)
• Programming languages are essential tools used to
communicate instructions to computers.
• They bridge the gap between human-readable code
and machine-executable instructions.
Computer Languages
• Machine Language
• Uses binary code
• Machine-dependent
• Not portable
• Assembly Language
– Uses mnemonics
– Machine-dependent
– Not usually portable
• High-Level Language (HLL)
– Uses English-like language
– Machine independent
– Portable (but must be compiled for different platforms)
– Examples: Python, C, C++, Java, Fortran, . . .
Compilation
• Compiler translates source into target (a machine language
program)
• Compiler goes away at execution time
• Compiler is itself a machine language program
Compiler
Target Program
Source
Program
Target
Program
Input Output
Program Execution
• Steps taken by the CPU to run a program
(instructions are in machine language):
1. Fetch an instruction
2. Decode (interpret) the instruction
3. Retrieve data, if needed
4. Execute (perform) actual processing
5. Store the results, if needed
Write/Edit
Run
with some input
OK?
YES
More
Inputs?
YES
NO
NO
Program Cycle
Program Errors
• Syntax Errors:
– Errors in grammar of the language
• Runtime error:
– When there are no syntax errors, but the program can’t
complete execution
• Divide by zero
• Invalid input data
• Logical errors:
– The program completes execution, but delivers incorrect
results
– Incorrect usage of parentheses
How to use Python in your PC
• You can install the python software from
http://python.org/downloads/
• You can use the Python IDE (integrated development
environment) like PyCharm, Anaconda, Jupiter
notebook, etc.
• You can use online Python compiler like
www.onlinegdb.com
Ways to run the Python program
1. Running Python in interactive mode:
2. Running Python in script mode:
User Program
Filename as Hello with extension as py
• Working with the interactive mode is better when
Python programmers deal with small pieces of code
as you can type and execute them immediately, but
when the code is more than 2-4 lines, using the script
for coding can help to modify and use the code in
future
x,y = 6,10
if x < y:
print (x)
else:
print (y)
print (‘is the min’)
x y
6 10
Run the program
Output
6
Indentation
• Indentation is important in Python
– grouping of statement (block of statements)
– no explicit brackets, e.g. { }, to group statements
skipped
INPUT ( ) FUNCTION
INPUT ( ) FUNCTION
INPUT ( ) FUNCTION
INPUT ( ) FUNCTION
Input( ) Function is a built in function of
Input( ) Function is a built in function of
python used to read values from the user as a
python used to read values from the user as a
string type.
string type.
The general format or syntax of the input() is:
The general format or syntax of the input() is:
variableName =input(message)
variableName =input(message)
For Example:
For Example:
Where,
Where,
variableName
variableName is a variable which is the label
is a variable which is the label
for a memory location where the value is
for a memory location where the value is
stored.
stored.
INPUT ( ) FUNCTION
INPUT ( ) FUNCTION
For Example:
For Example:
p = input(“Enter the value”)
p = input(“Enter the value”)
Note: it will read the value as string (non-numeric).
Note: it will read the value as string (non-numeric).
x = int(input(“Enter x value”))
x = int(input(“Enter x value”))
reads the value and converts it in to integer type
reads the value and converts it in to integer type
data or value.
data or value.
y=float(input(“Enter y value”))
y=float(input(“Enter y value”))
reads the value and converts it in to float type
reads the value and converts it in to float type
data or value.
data or value.
INPUT ( ) FUNCTION
INPUT ( ) FUNCTION
int ( ) and float ( ) Functions:
int ( ) and float ( ) Functions:
Python offers two functions to be used
Python offers two functions to be used
with input( ) to convert the received values:
with input( ) to convert the received values:
Example 1:
Example 1: >>age = int(input(“Enter age”))
>>age = int(input(“Enter age”))
Example 2:
Example 2: >>sal=float(input(“Enter salary))
>>sal=float(input(“Enter salary))
PRINT ( ) FUNCTION
PRINT ( ) FUNCTION
PRINT ( ) FUNCTION
PRINT ( ) FUNCTION
print( )
print( ) Function is a built in function of
Function is a built in function of
python used to display the values on the
python used to display the values on the
screen
screen
The general format or syntax of the input() is:
The general format or syntax of the input() is:
Print(“message”, variable)
Print(“message”, variable)
The print function can print an arbitrary
The print function can print an arbitrary
number of values ("value1, value2, ..."), which are
number of values ("value1, value2, ..."), which are
separated by commas. These values are separated
separated by commas. These values are separated
by blanks. In the following example we can see
by blanks. In the following example we can see
two print calls. We are printing two values in both
two print calls. We are printing two values in both
cases, i.e. a string and a float number:
cases, i.e. a string and a float number:
PRINT ( ) FUNCTION
PRINT ( ) FUNCTION
print("Python is fun.")
print("Python is fun.")
a = 5
a = 5
#Two objects are passed:
#Two objects are passed:
print("a =", a)
print("a =", a)
b = a
b = a
# Three objects are passed:
# Three objects are passed:
print('a =', a, '= b‘)
print('a =', a, '= b‘)
Output
Output
Python is fun.
Python is fun.
a = 5
a = 5
a = 5 = b
a = 5 = b
Example 1: How print() works in Python?
Example 1: How print() works in Python?
PRINT ( ) FUNCTION
PRINT ( ) FUNCTION
>>> print("a = ", a)
>>> print("a = ", a)
a = 3.564
a = 3.564
>>> print("a = n", a)
>>> print("a = n", a)
a =
a =
3.564
3.564
>>>
>>>
Example 2: How print() works in Python?
Example 2: How print() works in Python?
Simple problems in Python:
• Print “Hello Word!”
• Add two integer numbers
• Multiplication of two numbers.
• Compute average of 3 numbers.
• Find area of rectangle.
• Find area of square
• Find area of circle
• Find perimeter of rectangle.
Any Questions Please
Any Questions Please

More Related Content

Similar to Python Programming Introduction demo.ppt (20)

INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptx
Nimrahafzal1
 
Introduction to phyton , important topic
Introduction to phyton , important topicIntroduction to phyton , important topic
Introduction to phyton , important topic
akpgenious67
 
Python for beginner, learn python from scratch.pptx
Python for beginner,  learn python from scratch.pptxPython for beginner,  learn python from scratch.pptx
Python for beginner, learn python from scratch.pptx
olieee2023
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
KosmikTech1
 
Python knowledge ,......................
Python knowledge ,......................Python knowledge ,......................
Python knowledge ,......................
sabith777a
 
PYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdfPYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdf
Ramakrishna Reddy Bijjam
 
Introduction to learn and Python Interpreter
Introduction to learn and Python InterpreterIntroduction to learn and Python Interpreter
Introduction to learn and Python Interpreter
Alamelu
 
Keep it Stupidly Simple Introduce Python
Keep it Stupidly Simple Introduce PythonKeep it Stupidly Simple Introduce Python
Keep it Stupidly Simple Introduce Python
SushJalai
 
Python basics_ part1
Python basics_ part1Python basics_ part1
Python basics_ part1
Elaf A.Saeed
 
IMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxIMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptx
lemonchoos
 
Chapter 0 Python Overview (Python Programming Lecture)
Chapter 0 Python Overview (Python Programming Lecture)Chapter 0 Python Overview (Python Programming Lecture)
Chapter 0 Python Overview (Python Programming Lecture)
IoT Code Lab
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
Kamal Acharya
 
Python 01.pptx
Python 01.pptxPython 01.pptx
Python 01.pptx
AliMohammadAmiri
 
Chapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxChapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptx
lemonchoos
 
#Code2Create: Python Basics
#Code2Create: Python Basics#Code2Create: Python Basics
#Code2Create: Python Basics
GDGKuwaitGoogleDevel
 
Python Data Types
Python Data TypesPython Data Types
Python Data Types
athithanvijay
 
Unit2 input output
Unit2 input outputUnit2 input output
Unit2 input output
deepak kumbhar
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1
Abdul Haseeb
 
python.pdf
python.pdfpython.pdf
python.pdf
BurugollaRavi1
 
introduction to python programming concepts
introduction to python programming conceptsintroduction to python programming concepts
introduction to python programming concepts
GautamDharamrajChouh
 
INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptx
Nimrahafzal1
 
Introduction to phyton , important topic
Introduction to phyton , important topicIntroduction to phyton , important topic
Introduction to phyton , important topic
akpgenious67
 
Python for beginner, learn python from scratch.pptx
Python for beginner,  learn python from scratch.pptxPython for beginner,  learn python from scratch.pptx
Python for beginner, learn python from scratch.pptx
olieee2023
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
KosmikTech1
 
Python knowledge ,......................
Python knowledge ,......................Python knowledge ,......................
Python knowledge ,......................
sabith777a
 
Introduction to learn and Python Interpreter
Introduction to learn and Python InterpreterIntroduction to learn and Python Interpreter
Introduction to learn and Python Interpreter
Alamelu
 
Keep it Stupidly Simple Introduce Python
Keep it Stupidly Simple Introduce PythonKeep it Stupidly Simple Introduce Python
Keep it Stupidly Simple Introduce Python
SushJalai
 
Python basics_ part1
Python basics_ part1Python basics_ part1
Python basics_ part1
Elaf A.Saeed
 
IMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxIMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptx
lemonchoos
 
Chapter 0 Python Overview (Python Programming Lecture)
Chapter 0 Python Overview (Python Programming Lecture)Chapter 0 Python Overview (Python Programming Lecture)
Chapter 0 Python Overview (Python Programming Lecture)
IoT Code Lab
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
Kamal Acharya
 
Chapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxChapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptx
lemonchoos
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1
Abdul Haseeb
 
introduction to python programming concepts
introduction to python programming conceptsintroduction to python programming concepts
introduction to python programming concepts
GautamDharamrajChouh
 

Recently uploaded (20)

Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
National Information Standards Organization (NISO)
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
Quiz Club of PSG College of Arts & Science
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
Quiz Club of PSG College of Arts & Science
 
LDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad UpdatesLDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad Updates
LDM & Mia eStudios
 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
LDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad UpdatesLDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad Updates
LDM & Mia eStudios
 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
Ad

Python Programming Introduction demo.ppt

  • 1. Introduction to Programming Language (Python)
  • 2. • Programming languages are essential tools used to communicate instructions to computers. • They bridge the gap between human-readable code and machine-executable instructions.
  • 3. Computer Languages • Machine Language • Uses binary code • Machine-dependent • Not portable • Assembly Language – Uses mnemonics – Machine-dependent – Not usually portable • High-Level Language (HLL) – Uses English-like language – Machine independent – Portable (but must be compiled for different platforms) – Examples: Python, C, C++, Java, Fortran, . . .
  • 4. Compilation • Compiler translates source into target (a machine language program) • Compiler goes away at execution time • Compiler is itself a machine language program Compiler Target Program Source Program Target Program Input Output
  • 5. Program Execution • Steps taken by the CPU to run a program (instructions are in machine language): 1. Fetch an instruction 2. Decode (interpret) the instruction 3. Retrieve data, if needed 4. Execute (perform) actual processing 5. Store the results, if needed
  • 7. Program Errors • Syntax Errors: – Errors in grammar of the language • Runtime error: – When there are no syntax errors, but the program can’t complete execution • Divide by zero • Invalid input data • Logical errors: – The program completes execution, but delivers incorrect results – Incorrect usage of parentheses
  • 8. How to use Python in your PC • You can install the python software from http://python.org/downloads/ • You can use the Python IDE (integrated development environment) like PyCharm, Anaconda, Jupiter notebook, etc. • You can use online Python compiler like www.onlinegdb.com
  • 9. Ways to run the Python program 1. Running Python in interactive mode:
  • 10. 2. Running Python in script mode: User Program Filename as Hello with extension as py
  • 11. • Working with the interactive mode is better when Python programmers deal with small pieces of code as you can type and execute them immediately, but when the code is more than 2-4 lines, using the script for coding can help to modify and use the code in future
  • 12. x,y = 6,10 if x < y: print (x) else: print (y) print (‘is the min’) x y 6 10 Run the program Output 6 Indentation • Indentation is important in Python – grouping of statement (block of statements) – no explicit brackets, e.g. { }, to group statements skipped
  • 13. INPUT ( ) FUNCTION INPUT ( ) FUNCTION
  • 14. INPUT ( ) FUNCTION INPUT ( ) FUNCTION Input( ) Function is a built in function of Input( ) Function is a built in function of python used to read values from the user as a python used to read values from the user as a string type. string type. The general format or syntax of the input() is: The general format or syntax of the input() is: variableName =input(message) variableName =input(message) For Example: For Example: Where, Where, variableName variableName is a variable which is the label is a variable which is the label for a memory location where the value is for a memory location where the value is stored. stored.
  • 15. INPUT ( ) FUNCTION INPUT ( ) FUNCTION For Example: For Example: p = input(“Enter the value”) p = input(“Enter the value”) Note: it will read the value as string (non-numeric). Note: it will read the value as string (non-numeric). x = int(input(“Enter x value”)) x = int(input(“Enter x value”)) reads the value and converts it in to integer type reads the value and converts it in to integer type data or value. data or value. y=float(input(“Enter y value”)) y=float(input(“Enter y value”)) reads the value and converts it in to float type reads the value and converts it in to float type data or value. data or value.
  • 16. INPUT ( ) FUNCTION INPUT ( ) FUNCTION int ( ) and float ( ) Functions: int ( ) and float ( ) Functions: Python offers two functions to be used Python offers two functions to be used with input( ) to convert the received values: with input( ) to convert the received values: Example 1: Example 1: >>age = int(input(“Enter age”)) >>age = int(input(“Enter age”)) Example 2: Example 2: >>sal=float(input(“Enter salary)) >>sal=float(input(“Enter salary))
  • 17. PRINT ( ) FUNCTION PRINT ( ) FUNCTION
  • 18. PRINT ( ) FUNCTION PRINT ( ) FUNCTION print( ) print( ) Function is a built in function of Function is a built in function of python used to display the values on the python used to display the values on the screen screen The general format or syntax of the input() is: The general format or syntax of the input() is: Print(“message”, variable) Print(“message”, variable) The print function can print an arbitrary The print function can print an arbitrary number of values ("value1, value2, ..."), which are number of values ("value1, value2, ..."), which are separated by commas. These values are separated separated by commas. These values are separated by blanks. In the following example we can see by blanks. In the following example we can see two print calls. We are printing two values in both two print calls. We are printing two values in both cases, i.e. a string and a float number: cases, i.e. a string and a float number:
  • 19. PRINT ( ) FUNCTION PRINT ( ) FUNCTION print("Python is fun.") print("Python is fun.") a = 5 a = 5 #Two objects are passed: #Two objects are passed: print("a =", a) print("a =", a) b = a b = a # Three objects are passed: # Three objects are passed: print('a =', a, '= b‘) print('a =', a, '= b‘) Output Output Python is fun. Python is fun. a = 5 a = 5 a = 5 = b a = 5 = b Example 1: How print() works in Python? Example 1: How print() works in Python?
  • 20. PRINT ( ) FUNCTION PRINT ( ) FUNCTION >>> print("a = ", a) >>> print("a = ", a) a = 3.564 a = 3.564 >>> print("a = n", a) >>> print("a = n", a) a = a = 3.564 3.564 >>> >>> Example 2: How print() works in Python? Example 2: How print() works in Python?
  • 21. Simple problems in Python: • Print “Hello Word!” • Add two integer numbers • Multiplication of two numbers. • Compute average of 3 numbers. • Find area of rectangle. • Find area of square • Find area of circle • Find perimeter of rectangle.
  • 22. Any Questions Please Any Questions Please