SlideShare a Scribd company logo
msbacademy.org
Python
Input ,processing and output
msbacademy.org
The Program Development Cycle
Design the
program
Write the
code
Correct
syntax errors
Test the
Program
Correct Logic
Errors
msbacademy.org
Output Statement in Python
print( ) : it display the output on the screen. print() function is
built in function of python.
ex: print(“hello world”)
out put: hello world
msbacademy.org
String and String Literals
String:
a sequence of characters that is used as data is called a string.
String Literals
When a string appears in the actual code of a program
it is called a string literal. In Python code, string literals must be
enclosed in quote marks.
msbacademy.org
Quotes
Quotes are optional in python
Note : 1. use a single quote always in double quotes
2. use a double quote always in triple quotes
msbacademy.org
Comments
Comments in Python start with the hash character, # , and
extend to the end of the physical line.
Example
# This program displays welcome to python programming
Print(“welcome to python programming”)
msbacademy.org
Variable
Variables are nothing but reserved memory locations to store
values. This means that when you create a variable you reserve
some space in memory.
Syntax : Variable=expression
salary=12000
.
msbacademy.org
Variable
Note:
You cannot use a variable until you have assigned a value to it
an error will occur if you try to perform an operation on a variable,
such as printing it, before it has been assigned a value.
msbacademy.org
Variable Naming Rules
Rules:
1. You cannot use one of Python’s key words as a variable
name.
2. A variable name cannot contain spaces.
3. The first character must be one of the letters a through z, A
through Z, or an underscore character (_).
4. After the first character you may use the letters a through z or
A through Z, the digitsb0 through 9, or underscores.
5. Uppercase and lowercase characters are distinct
msbacademy.org
Variable Naming Rules
variable name Legal or Illegal
salary legal
4sum illegal
_abcd legal
while illegal
Max salary illegal
msbacademy.org
Variable Reassignment
Variables are called “variable” because they can reference
different values while a program is running. When you assign a
value to a variable, the variable will reference that value until you
assign it a different value.
msbacademy.org
Variable Reassignment Example
Balance=10000
Print(“my account balance is”,Balance)
Balance=20000
Print(“my account balance is”,Balance)
msbacademy.org
Numeric Data Types and Literals
Numeric Data types
1. Int (When an integer is stored in memory, it is classified as
an int )
2. Float (When a real is stored in memory, it is classified as
a float )
Literals
3.Str (When string literal is stored in memory, it is classified as
a string)
msbacademy.org
Reading Input from the Keyboard
Input(): Python’s built-in input function to read input from the
keyboard.
Syntax:
Variable=input()
Note
it returns string values
msbacademy.org
Reading Numbers with the input Function
Variable=int(input())
Ex: a=int(“enter a value”)
Variable=float(input())
Ex : avg=float(input())
msbacademy.org
Operators
1. Arithmetic Operators
2. Comparison Operators
3. Assignment Operators
4. Logical Operators
5. Membership Operators
6. Identity Operators
msbacademy.org
Arithmetic Operators
Symbol operation
+ Addition
- Subtraction
* Multiplication
/ Division
// Integer division
% Remainder
** Exponent
msbacademy.org
Comparison Operators
Symbol operation
== Equal to
!= Not equal to
<= Less than or equal to
>= Greater than equal to
< Less than
> Greater than equal
msbacademy.org
Assignment Operators
Symbol operation
+= x=x+y is x+=y
-= x=x-y is x-=y
/= x=x/y is x/=y
//= x=x//y is x//=y
%= x=x%y is x%=y
*= x=x+y is x+=y
msbacademy.org
Logical Operators
1. AND
2. OR
3. NOT
msbacademy.org
Logical AND Table
1. (Logical and)
P Q P and Q
T T T
F F F
T F F
F T F
msbacademy.org
Logical OR Table
2. (Logical OR)
P Q P or Q
T T T
F F F
T F T
F T T
msbacademy.org
Logical NOT Operators
3. (Logical NOT)
P not P
T F
F T
msbacademy.org
Membership Operators
1. These operators test for membership in a sequence such as
lists, strings or tuples. There are two membership operators
that are used in Python. (in, not in). It gives the result based
on the variable present in specified sequence or string
msbacademy.org
Identity Operators
1. To compare the memory location of two objects, Identity
Operators are used. The two identify operators used in Python
are (is, is not).
msbacademy.org
Operators Precedence
Operators (Decreasing order
of precedence)
Meaning
** Exponent
*, /, //, % Multiplication, Division, Floor division,
Modulus
+, - Addition, Subtraction
<= < > >= Comparison operators
= %= /= //= -= += *= **= Assignment Operators
is ,is not Identity operators
in not in Membership operators
not or and Logical operators
msbacademy.org
Mixed-Type Expressions and Data Type Conversion
1. When an operation is performed on two int values, the result
will be an int.
2. When an operation is performed on two float values, the result
will be a float
3. When an operation is performed on an int and a float, the int
value will be temporarily converted to a float and the result of
the operation will be a float.
msbacademy.org
Escape Characters
Escape Character Effect
n
t
'
’’

Causes output to be advanced to the next
line
Causes output to skip over to the next
horizontal tab position.
Causes a single quote mark to be printed.
Causes a double quote mark to be printed.
Causes a backslash character to be printed.
msbacademy.org
Formatting Numbers
1. When a floating-point number is displayed by the print
statement, it can appear with up to 12 significant digits.
Ex: toat_marks = 100.0
avg_marks = toat_marks / 3.0
print('Average marks is',avg_marks)
Output: Average marks is 33.3333333333
msbacademy.org
Formatting specifier
format(12345.6789, ‘.2f’)
1. .2 specifies two decimal spaces
2. The f specifies that the data type of the number we are
formatting is a floating-point number.
msbacademy.org
Formatting in Scientific Notation
If you want to display floating-point numbers in scientific
notation, you can use the letter e or the letter E instead of f.
print(format(33.333333333333,’.1e’)
Output
3.3e+1
msbacademy.org
Inserting Comma Separators
1. If you want the number to be formatted with comma
separators, you can insert a comma into the format specifier.
print(format(33333333.3333,’,.2f)
output
33,333,333.33
msbacademy.org
Specifying a Minimum Field Width
1. The format specifier can also include a minimum field width,
which is the minimum number of spaces that should be used
to display the value.
Ex:
print('The number is', format(14586.6889, '12.2f'))
output
The number is 14586.68
msbacademy.org
Formatting Integers
1. You use ‘d’ as the type designator.
2. You cannot specify precision.
Ex :
Print('The number is', format(125465,’,d’))
output
The number is 1,25,465
msbacademy.org
Follow Us:
/msbacademy
/msb academy
/msb_academy
/msb_academy
Thank You

More Related Content

What's hot (20)

Html text and formatting
Html text and formattingHtml text and formatting
Html text and formatting
 
Packages In Python Tutorial
Packages In Python TutorialPackages In Python Tutorial
Packages In Python Tutorial
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Immutable vs mutable data types in python
Immutable vs mutable data types in pythonImmutable vs mutable data types in python
Immutable vs mutable data types in python
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in python
 
Tuples in Python
Tuples in PythonTuples in Python
Tuples in Python
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Html forms
Html formsHtml forms
Html forms
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Nested loops
Nested loopsNested loops
Nested loops
 
String Manipulation in Python
String Manipulation in PythonString Manipulation in Python
String Manipulation in Python
 
Python list
Python listPython list
Python list
 
Python dictionary
Python   dictionaryPython   dictionary
Python dictionary
 
Python strings presentation
Python strings presentationPython strings presentation
Python strings presentation
 
Dictionaries in Python
Dictionaries in PythonDictionaries in Python
Dictionaries in Python
 
Coding theory updated
Coding theory updatedCoding theory updated
Coding theory updated
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and require
 

Similar to Input processing and output in Python

component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptxAnisZahirahAzman
 
Introduction to Python - Part Two
Introduction to Python - Part TwoIntroduction to Python - Part Two
Introduction to Python - Part Twoamiable_indian
 
Stream Based Input Output
Stream Based Input OutputStream Based Input Output
Stream Based Input OutputBharat17485
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshopBAINIDA
 
PPt Revision of the basics of python1.pptx
PPt Revision of the basics of python1.pptxPPt Revision of the basics of python1.pptx
PPt Revision of the basics of python1.pptxtcsonline1222
 
Introduction to Python Basics
Introduction to Python BasicsIntroduction to Python Basics
Introduction to Python BasicsRaghunath A
 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2dplunkett
 
TOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfTOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfEjazAlam23
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data TypesTareq Hasan
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| FundamentalsMohd Sajjad
 

Similar to Input processing and output in Python (20)

Python
PythonPython
Python
 
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptx
 
Python programming
Python  programmingPython  programming
Python programming
 
Python basics
Python basicsPython basics
Python basics
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Introduction to Python - Part Two
Introduction to Python - Part TwoIntroduction to Python - Part Two
Introduction to Python - Part Two
 
Token and operators
Token and operatorsToken and operators
Token and operators
 
vb.net.pdf
vb.net.pdfvb.net.pdf
vb.net.pdf
 
Stream Based Input Output
Stream Based Input OutputStream Based Input Output
Stream Based Input Output
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
 
Python 3.pptx
Python 3.pptxPython 3.pptx
Python 3.pptx
 
PPt Revision of the basics of python1.pptx
PPt Revision of the basics of python1.pptxPPt Revision of the basics of python1.pptx
PPt Revision of the basics of python1.pptx
 
Introduction to Python Basics
Introduction to Python BasicsIntroduction to Python Basics
Introduction to Python Basics
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2
 
TOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfTOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdf
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data Types
 
5 introduction-to-c
5 introduction-to-c5 introduction-to-c
5 introduction-to-c
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
 
Python-Cheat-Sheet.pdf
Python-Cheat-Sheet.pdfPython-Cheat-Sheet.pdf
Python-Cheat-Sheet.pdf
 

Recently uploaded

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...Product School
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsVlad Stirbu
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...Sri Ambati
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsExpeed Software
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2DianaGray10
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupCatarinaPereira64715
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 

Recently uploaded (20)

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 

Input processing and output in Python