INPUT AND PRINT

INPUT
PYTHON allows a user to give input and based on that a program will proceed further.
In python, we pass some value to input() so that it tell the user what to give input.let us look at the exmaple below;

UserName= input ("Enter name:")
Print ("The name of user is" + username)

in the above example, the user is asked to enter his/name. if the user entered "Piyush", the output will be: The name of the user is Piyush.

PRINT

We use the print () function to output data to screen. for example;
Print('this sentence is output to the)
Output of the above code would be : this sentence is output to the screen 

We can also print the value assigned to a variable.
a=5
print('the value of a is', a 
   
output of the above code would be the value of a is 5

# Print the string "Hello World"
print("Hello World")

# Create a variable named myName and
# set it to input("enter your name")
myName = input("enter your name");

# Create a variable named myAge and
# set it to int(input("enter your age"))
myAge = int(input ("enter your age"));

# Add myName as the second argument
# in the following print command
print("Hello, my name is ", myName  )

# Add myAge as the second argument
# in the following print command
print("My age is ",   myAge   )


   

 

Comments