Q:

Python | Typecasting Input to Integer, Float

belongs to collection: Python basic programs

0

Python | Typecasting Input to Integer, Float

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python basic programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
How to check multiple variables against a value in... >>
<< Create integer variable by assigning hexadecimal v...