![]() |
| Taking User Input in Python |
User input in Python: A python user input is a predefined function in python library which is used to take user input in Python. Default user input is of type string in python.
Python User Input String
print("Your Name is:", name) print(type(name)) ============OUTPUT============ Enter Your Name: Jiocoding Your Name is: Jiocoding <class 'str'> |
Python User Input Integer
Integer User Input: A interger user input is a predefined function which is used to convert string into integer that is called type casting one type to another type.
Example of Integer User Input in Python
x=int(x) y=input("Enter Second Number:") y=int(y) add=x+y print("Addition of X+Y:", add) print(type(add)) ============OUTPUT============ Enter First Number:78 Enter First Number:23 Addition of X+Y:101 <class 'int'> |
Second Method Integer User Input in Python
y=int(input("Enter Second Number:")) add=x+y print("Addition of X+Y:", add) print(type(add)) ============OUTPUT============ Enter First Number:78 Enter First Number:23 Addition of X+Y:101 <class 'int'> |
Taking Float Value User Input in Python
Float User Input: A float user input is a predefined function which is used to convert string into float.
Example of Float User Input in Python
x=float(x) y=input("Enter Second Number:") y=float(y) add=x+y print("Addition of X+Y:", add) print(type(add)) ============OUTPUT============ Enter First Number:7.8 Enter First Number:2.3 Addition of X+Y:10.1 <class 'float'> |
Second Method Float User Input in Python
y=float(input("Enter Second Number:")) add=x+y print("Addition of X+Y:", add) print(type(add)) ============OUTPUT============ Enter First Number:7.8 Enter First Number:5.3 Addition of X+Y:13.1 <class 'float'> |
Conclusion of Python User Input
Conclusion: A python user input is a very important important part of programming because users can be used dynamically input by user. I am explain python user input with example if your any query python user input related you can contact me by email or comment.

0 Comments