Reading input from End-user :
- input() function is pre-defined.
- It is used to read input while application is running.
- It returns the input in String format only
- We need to convert these String type input values into corresponding type for processing
print(“Enter your name :”) name = input() print(“Hello,”,name) |
Note: We can give the prompt while reading input
name = input(“Enter your name : “) print(“Hello,”,name) |
Note: Every input value will be returned in String format only.
print(“Enter 2 numbers :”) a = input() b = input() c = a+b # “5” + “6” = “56” print(“Sum :”,c) |
int( ) :
- It is pre-defined function
- It can convert input value into integer type.
- On success, it returns integer value
- On failure(if the input is not valid, raised error)
Adding 2 numbers
print(“Enter 2 numbers :”) a = input() b = input() c = int(a)+int(b) print(“Sum :”,c) |