Taking Numeric Input

Lesson Progress
0% Complete

For getting numeric type input, we must type cast it to int or float.

# simple input method in python
default_type_variable = input("Input any type of data\n")
# default type is string data
print("type of the data entered: ",type(default_type_variable)," Value = ", default_type_variable)
# defining type of data to be entered input
# Integer Data - type casting
my_int_data = int(input("enter integer type data\n"))
print("type of the data entered: ",type(my_int_data)," Value = ", my_int_data)

# Float Data - type casting
my_float_data = float(input("enter decimal/float type data\n"))
print("type of the data entered: ",type(my_float_data)," Value = ", my_float_data)