Python
Input & Output
in programming
Stage 1 | level 3 – Output & Input PYTHON
Input & Output in python
????
Diagrammatic representation
Input Process output
Stage 1 | level 3 – Input & Output PYTHON
Input
Input
Developers often The input() method
For taking basic input
have a need to reads a line from
from user python has
interact with users, input, converts into a
one simple function
either to get data string and returns it
or to provide
some sort of result
The syntax of input( ) method is
Stage 1 | level 3 – Input & Output PYTHON
Input function working
Input
How input( ) works in Python?
Data stored
The input( ) function The input() method reads a
takes a single line from the input (usually
optional argument from the user), converts the
called prompt line into string and returns it.
A string that is written to
standard output (usually
screen) without trailing
newline
Stage 1 | level 3 – Input & Output PYTHON
The datatype of user input
Input
Code
3 variables The value returned
from input( ) function
name age school is always string data
type
All of string datatype
Stage 1 | level 3 – Input & Output PYTHON
Try coding
Stage 1 | level 3 – Output & Input PYTHON
Casting in python
Input
str
Casting is when you convert
a variable value from one
type to another.
int
Stage 1 | level 3 – Input & Output PYTHON
Casting in python
Because string
In python, its done with functions values don’t
work like math
such as int() or float() or str().
‘100-90’
10 1.232
float
1
Run all code lines in different int
cell for better understanding
Stage 1 | level 3 – Input & Output PYTHON
Activity 1
Stage 1 | level 3 – Output & Input PYTHON
Write down the datatype given in code below ?
Stage 1 | level 3 – Output & Input PYTHON
Input & Output in python
????
Diagrammatic representation
Input Process output
input() and print() are widely used for standard input and output operations respectively
Stage 1 | level 3 – Input & Output PYTHON
Output
output
print( ) function
We use the print() function
to output data to the
standard output device
(screen)
Output formatting
you can pass zero or more
Output formatting is when you want expressions separated by
to display the output making it more commas
attractive and understandable
The syntax of print function
is simple until you want to
understand all options.
Stage 1 | level 3 – Input & Output PYTHON
Print function
output
print( ) function
So, to understand the program
When you just put a variable in When we display output using
ourselves we can use both but to
cell to see output, its known as print( ) function its called
display information correctly we
raw output formatted output
have to use print() function
Passing data
As you can see, we can pass
variable in print. Also we can mix ‘Harry potter’
other datatypes in one print( )
function Harry potter Clean output
Stage 1 | level 3 – Input & Output PYTHON
Formatting print
output
print( ) function
1234
1*2*3*4
1#2#3#4&
Stage 1 | level 3 – Input & Output PYTHON
Formatting print
output
Output formatting formatting?
Attractively designing your string using
formatting techniques provided by the
particular programming language.
We have different string formatting
i will purchase 10 fruit today
techniques in Python.
the new f-string formatting technique, is the
best way to format output. There are older
techniques that we will discuss later
digipodium is an Educational company.
Stage 1 | level 3 – Input & Output PYTHON
Try coding
Stage 1 | level 3 – Output & Input PYTHON
Assignment for
level 3
click here
Stage 1 | level 3 – Output & Input PYTHON
THE END
Stage 1 | level 3 – Output & Input PYTHON