Skip to main content
Contents
Search Book
Search Results:
No results.
Readability settings Prev Up Next Scratch ActiveCode Profile
title here
\(
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
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
Checkpoint 16.9.1 .
Study the code below and answer the questions.
name = "Raya"
print("Hello")
print(name)
Which line prints a string literal?
Which line prints the value stored in a variable?
What is the purpose of print()?
Subsection 16.9.3 Part B: Predict the Output
Checkpoint 16.9.2 .
Checkpoint 16.9.3 .
name = "Jordan"
print("Hello, " + name + "!")
Checkpoint 16.9.4 .
Checkpoint 16.9.5 .
Subsection 16.9.4 Part C: Explain
Checkpoint 16.9.6 .
Explain the difference between each pair.
print("5") and print(5)
print(name) and print("name")
print("Age:", 18) and print("Age: " + "18")
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 .
Write code for each task.
Print the message βWelcome to CS1!β
Create a variable named score with the value 95 and print it.
Create a variable named name and print the greeting βHello, <name>!β
Print the result of adding 8 and 2.
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.