File input-output in python
File input-output in python
Display message in screen:
In python, the only way to print a message on the output window is done by a print statement where you can pass any expression or statements under double-quotes. The print () function converts the expression and writes on the slandered output screen.
Example:
# Here print() is used to display message
print ("Python is powerful language")
Taking Input from Screen:
Python language gives some functions to perform the reading of the text from the given slandered input which comes from machine input by keyword. There are two functions which deal with reading operations:
A. raw-_input
B. input
raw_input Function in Python:
This function generally reads the slandered inputs and then returns as String removing trailing newlines.
Example:
rawstring = raw_input("Enter some message- ")
print ("input is : ", rawstring)
input Function in Python:
This function takes input as a valid python expression and returns the calculated (evaluated ) result in the output.
Example:
#input() function perform calculation of program
rawstring = input("Enter some message- ")
print ("input is : ", rawstring)
#output
#Enter some message: [x*5 for x in range(2,10,2)]
#input is : [10, 20, 30, 40]
