Section 16.10 Review - Input
Practice using
input() to get values from the user and understand that input() returns a string.
Subsection 16.10.1 Quick Reference
input() gets information typed by the user. The value returned by input() is always a str. Use int() or float() if you want to convert the input to a number.
name = input("Enter your name: ")
age = int(input("Enter your age: "))
Subsection 16.10.2 Part A: Recognize
Subsection 16.10.3 Part B: Predict What Happens
Checkpoint 16.10.2.
If the user types
Raya, what is printed given the following code snippet?
name = input("Enter your name: ")
print("Hello, " + name)
Checkpoint 16.10.3.
age = input("Enter your age: ")
print(age)
Checkpoint 16.10.4.
If the user types
5, what is printed given the following code snippet?
num = input("Enter a number: ")
print(num + num)
Subsection 16.10.4 Part C: Explain
Checkpoint 16.10.5.
What is the difference between these two lines?
value = input("Enter a number: ")
value = int(input("Enter a number: "))
Subsection 16.10.5 Part D: Fix
Checkpoint 16.10.6.
Rewrite the code so it works correctly.
Checkpoint 16.10.7.
Rewrite the code so it works correctly.
Checkpoint 16.10.8.
Rewrite the code so it works correctly.
Subsection 16.10.6 Part E: Create
Checkpoint 16.10.9.
Write code that asks the user for their name and prints a greeting. Then asks for their favorite number and prints it back. Finally, it asks the user for two whole numbers, and prints their sum.
Subsection 16.10.7 Think About ...
Checkpoint 16.10.10.
You have attempted of activities on this page.
