User Input in Python

 '''

User Input in Python

In Python, we can take user input directly by using input() function.


variable=input()


But input function returns the value as a string only. So we have to typecast them whenever requires to another datatype.

'''


a = input("Enter your name: " ,)

print("My name is", a)

#output= My name is Sindhu


'''While writing an input statement, we need to have some space for the data to be stored for the user to input. After using a string statement to give instruction, to the user to make sure to have a comma after the string statement.'''


x = input("Enter first number: " ,)

y = input("Ener second number: " ,)

print(int(x) + int(y))

#output=33

Comments

Popular posts from this blog

Print Function

Arithmetic Operators

Sets in Python