Input and output operations
Input and output operations
.
Input & output
operations in
Python
Input & output Operations
● I/O Statements
● Escape Sequences
● Formatted I/O
Input & output statements
wHat are i/0
statements?
Example:
#Enter a input
a = input()
Print(a) Output
a=3
Input function
wHat is input
Function?
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.
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.
separator
end
file
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 The value of x is 15
Curly braces y = 20
print('The value of x is {} and y is {}'.format(x,y)) and y is 20
print("line1 \
Backslash means new line1 line2 line3
\ line is ignored
line2 \
line3")
print("Python \n Python
\n New line
Programming") Programming
print("Python \t
\t ASCII Horizontal Tab (TAB)
Programming")
Python 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