Interaction with the user

Module 2 · Interaction with the user · Lesson 6 of 6

Quiz

Five questions on reading input, converting types and working with strings. Picture what Python does before you answer.

1

What type does input() always return?

2

The user types 5. What happens?

x = input()
print(x + 1)
3

How do you read a whole number from the user?

4

What does this print?

print("5" + "5")
5

What does this print?

print("-" * 5)

That completes the round trip: your programs can now read from a person, turn that input into the right type, and respond. Combined with variables and operators, you can write genuinely interactive little tools.