Python Module 4 I O
Python Module 4 I O
Python Module 4 I O
.
Input & output
operations in
Python
Input & output Operations
● I/O Statements
● Escape Sequences
● Formatted I/O
Input & output statements
wHat are i/0
statements?
If you notice the above code, although the given input is of number the output is considered as a string data type.
You may use type conversion to convert the above number either into int or float data type.
Output
The value of a is 5
Standard print () function
Syntax
sep - The separator is used between the values. It defaults into a space
character.
After all values are printed, the specified end symbol is printed. By default
it creates a new line.
The file is the object where the values are printed and its default value is
sys.stdout (screen). The flush makes sure that any output that is buffered
goes to the destination.
Standard print () function
Object
s
Objects is the value or values to be printed.
File (file) is the object where the values are printed and
its default is sys.stdout (screen).
Standard print () function
flush
Output
I am 20 years old
output formatting
String formatting
examples
Input Output
x = 15
y = 20 The value of x is 15 and y is 20
print('The value of x is {} and y is {}'.format(x,y))
print("Python \n Python
\n New line
Programming") Programming
print("Python \t
\t ASCII Horizontal Tab (TAB) Python Programming
Programming")
Output formatting
% Operator -
float
Input Output Remarks
Output
['I', 'Love', 'Python', 'Programming']
Map Function
What is Map
Function?
Example
x, y, z = map(int,input("enter numbers: ").split())
print(x+y+z)
Output
enter numbers: 1 2 3
6