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

PPT
Input and output in C++
PPTX
Chapter 03 python libraries
PPTX
The Stack And Recursion
PPT
File handling in c
PDF
Arrays in python
PPTX
Member Function in C++
DOC
Arrays and Strings
Input and output in C++
Chapter 03 python libraries
The Stack And Recursion
File handling in c
Arrays in python
Member Function in C++
Arrays and Strings

What's hot (20)

PDF
Structures in c++
PPTX
Dynamic memory allocation in c
PDF
Java thread life cycle
PPTX
Regular expressions in Python
PPT
Queue data structure
PDF
Searching and Sorting Techniques in Data Structure
PDF
Python recursion
PPTX
Pointers in c++
PPTX
Group By, Having Clause and Order By clause
PDF
Data structure using c++
PPTX
Cpu scheduling in operating System.
PPTX
Function in C program
PPTX
Introduction to data structure ppt
PPTX
File handling in Python
PPTX
NESTED SUBQUERY.pptx
PDF
Strings in python
PPTX
Modules in Python Programming
PDF
Character Array and String
PDF
Arrays In Python | Python Array Operations | Edureka
PPT
Structure of C++ - R.D.Sivakumar
Structures in c++
Dynamic memory allocation in c
Java thread life cycle
Regular expressions in Python
Queue data structure
Searching and Sorting Techniques in Data Structure
Python recursion
Pointers in c++
Group By, Having Clause and Order By clause
Data structure using c++
Cpu scheduling in operating System.
Function in C program
Introduction to data structure ppt
File handling in Python
NESTED SUBQUERY.pptx
Strings in python
Modules in Python Programming
Character Array and String
Arrays In Python | Python Array Operations | Edureka
Structure of C++ - R.D.Sivakumar
Ad

Similar to Input processing and output in Python (20)

PPTX
PPTX
Learn about Python power point presentation
PPTX
component of c language.pptx
PPTX
Python programming
PPTX
Introduction on basic python and it's application
PPTX
Python basics
PPTX
Python.pptx
PPT
Introduction to Python - Part Two
PPTX
UNIT – 3.pptx for first year engineering
PPT
Token and operators
PPTX
ChapterTwoandThreefnfgncvdjhgjshgjdlahgjlhglj.pptx
PPTX
11-unit1chapter02pythonfundamentals-180823043011.pptx
PDF
vb.net.pdf
PPT
Stream Based Input Output
PPTX
Python programming workshop
PPTX
Python 3.pptx
PPTX
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
PDF
learn basic to advance C Programming Notes
PPTX
PPt Revision of the basics of python1.pptx
PPTX
Chapter 2-Python and control flow statement.pptx
Learn about Python power point presentation
component of c language.pptx
Python programming
Introduction on basic python and it's application
Python basics
Python.pptx
Introduction to Python - Part Two
UNIT – 3.pptx for first year engineering
Token and operators
ChapterTwoandThreefnfgncvdjhgjshgjdlahgjlhglj.pptx
11-unit1chapter02pythonfundamentals-180823043011.pptx
vb.net.pdf
Stream Based Input Output
Python programming workshop
Python 3.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
learn basic to advance C Programming Notes
PPt Revision of the basics of python1.pptx
Chapter 2-Python and control flow statement.pptx
Ad

Recently uploaded (20)

PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Advanced IT Governance
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Modernizing your data center with Dell and AMD
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
KodekX | Application Modernization Development
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
cuic standard and advanced reporting.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
GamePlan Trading System Review: Professional Trader's Honest Take
Advanced Soft Computing BINUS July 2025.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Advanced IT Governance
MYSQL Presentation for SQL database connectivity
Modernizing your data center with Dell and AMD
The Rise and Fall of 3GPP – Time for a Sabbatical?
Understanding_Digital_Forensics_Presentation.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
KodekX | Application Modernization Development
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
NewMind AI Weekly Chronicles - August'25 Week I
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
cuic standard and advanced reporting.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Transforming Manufacturing operations through Intelligent Integrations
madgavkar20181017ppt McKinsey Presentation.pdf

Input processing and output in Python