Section 16.9 Review - Output and print()
Practice using
print() to display output, predict what programs print, and fix common output mistakes.
Subsection 16.9.1 Quick Reference
print() displays output to the screen. It can print strings, numbers, variables, and expression results. When you print multiple values separated by commas, Python places a space between them in the output.
Subsection 16.9.2 Part A: Recognize
Subsection 16.9.3 Part B: Predict the Output
Checkpoint 16.9.2.
What is printed?
print("CS Rocks")
Checkpoint 16.9.3.
What is printed?
name = "Jordan"
print("Hello, " + name + "!")
Checkpoint 16.9.4.
What is printed?
x = 4
y = 6
print(x + y)
Checkpoint 16.9.5.
What is printed?
print("Age:", 18)
Subsection 16.9.4 Part C: Explain
Checkpoint 16.9.6.
Subsection 16.9.5 Part D: Fix
Checkpoint 16.9.7.
Rewrite the code so it works correctly.
Checkpoint 16.9.8.
Rewrite the code so it works correctly.
Checkpoint 16.9.9.
Rewrite the code so it prints the sentence βI am 18 years old.β
Subsection 16.9.6 Part E: Create
Checkpoint 16.9.10.
Subsection 16.9.7 Reflection
Checkpoint 16.9.11.
When should you print a value directly, and when is it helpful to store the value in a variable first?
You have attempted of activities on this page.
