Here, we will figure out how to typecast offered contribution to an integer, skim in Python?
To enter any worth, we use input() function – which is an inbuilt function.
Typecasting contribution to integer
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 contribution to integer
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