Home »
Python »
Python programs
Python | Typecasting Input to Integer, Float
Here, we are going to learn how to typecast given input to integer, float in Python?
Submitted by IncludeHelp, on September 08, 2018
To input any value, we use input() function - which is an inbuilt function.
Typecasting input to integer
Syntax:
int(input())
Example:
# input a number
num = int(input("Input a value: "))
# printing input value
print "num = ", num
Output
Input a value: 10
num = 10
Typecasting Input to float
Syntax:
float(input())
Example:
# input a number
num = float(input("Input a value: "))
# printing input value
print "num = ", num
Output
Input a value: 10.23
num = 10.23
Python Basic Programs »