Input-Output

Accept string as input

word = input()

input always returns a string, no matter what input is entered.

Input word
good 'good'
123 '123'
12.3 '12.3'

Accept integer as input

x = int(input())

First accept a string as input and convert it into an integer. This conversion is often called type-casting, since we are changing the type of a variable. Here, it goes from str to int.

Accept float as input

x = float(input())

Similar to the previous how-to.