python
Get input as a number in python
You wanna know how to get input as a number in python, right? Don't we all. Well, it's really easy. You just do x = int(input('Please enter a number: ')) or x = float(input('Please enter a number: ')) if you want it as a floating-point number.
# For integer input
value = int(input("Enter a number: "))
# For float input
value = int(input("Enter a float number: "))
Was this helpful?
Similar Posts
- Get User input from terminal in Python
- Get the second largest number from a list in Python
- Get the number of days between two dates in Python
- How to generate a random number in python using random module
- Calculate the square root of a number in python
- Reverse a string or number in python
- Calculate the factorial of a number using python code