SlideShare a Scribd company logo
1 of 35
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)

Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
 
Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)
 
Learn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesLearn 90% of Python in 90 Minutes
Learn 90% of Python in 90 Minutes
 
Strings in C
Strings in CStrings in C
Strings in C
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Data types
Data typesData types
Data types
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Python basics
Python basicsPython basics
Python basics
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Python Control structures
Python Control structuresPython Control structures
Python Control structures
 
List in Python
List in PythonList in Python
List in Python
 
Dictionaries in Python
Dictionaries in PythonDictionaries in Python
Dictionaries in Python
 
Python programming : Standard Input and Output
Python programming : Standard Input and OutputPython programming : Standard Input and Output
Python programming : Standard Input and Output
 
C functions
C functionsC functions
C functions
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Files and streams
Files and streamsFiles and streams
Files and streams
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 

Similar to Python Input, Processing, Output, Variables, Data Types, Operators, Formatting Numbers

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
 
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
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxKoteswari Kasireddy
 

Similar to Python Input, Processing, Output, Variables, Data Types, Operators, Formatting Numbers (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
 
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
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 

Python Input, Processing, Output, Variables, Data Types, Operators, Formatting Numbers