Lesson 4 of 12

Getting User Input 👋

🎯 Grades 6–8 ⏱ ~25 minutes 💚 Intermediate

What You'll Learn

  • Use the input() function to get text from users
  • Convert input to a number with int() and float()
  • Build a program that responds to the user
Quick Check

1. What does input() always return?

AAn integer
BA string
CA float

2. How do you convert a string to an integer?

Astr()
Bfloat()
Cint()

3. Which line gets the user's name?

Aname = "Alex"
Bname = input("Your name? ")
Cprint(name)

4. The user types "7". What happens if you do input_val + 3 without converting?

AResult is 10
BTypeError — can't add str and int
CResult is "73"