Computer Science
Grade 3
20 min
Using Print Statements: Displaying Values
Students will learn how to use print statements to display the values of variables and identify unexpected behavior.
Tutorial Preview
1
Introduction & Learning Objectives
Learning Objectives
Explain that a print statement shows information on the screen.
Write a print statement to display a specific text message (a string).
Write a print statement to display the number stored in a variable.
Identify the difference between printing a text message and printing a variable's value.
Use a print statement to check the value of a variable at a specific point in a program.
Find and fix simple errors in print statements, like missing quotation marks.
Have you ever wanted your computer to talk to you or show you a secret message? 🕵️♀️ Let's learn how to make it happen!
We are going to learn about a special command called a 'print statement'. This command is like a magnifying glass that lets us see what's happening inside our...
2
Key Concepts & Vocabulary
TermDefinitionExample
Print StatementA command that tells the computer to show something on the screen, like a message or a number.The code `print("Hello!")` tells the computer to display the word Hello! on the screen.
ValueA single piece of information, like a number (5) or some text ("apple").In `score = 100`, the value is 100.
VariableA container with a name that holds a value. Think of it like a labeled box that you can put things in.`player_name` could be a variable that holds the value "Zoe".
StringA fancy word for text, letters, or words. In code, we always put strings inside quotation marks."Welcome, Detective!" is a string.
OutputThe information that the computer shows on the screen after running a print statement.If your code is `print(5)`...
3
Core Syntax & Patterns
Printing Text (Strings)
print("Your text goes here")
To show a message or any words on the screen, you must put them inside quotation marks `" "` inside the parentheses.
Printing a Variable's Value
print(variable_name)
To show the value that is stored inside a variable, you just put the variable's name inside the parentheses. Do NOT use quotation marks!
4 more steps in this tutorial
Sign up free to access the complete tutorial with worked examples and practice.
Sign Up Free to ContinueSample Practice Questions
Challenging
A detective's code is supposed to show how many clues are left. What is the problem with this code?
`clues_left = 6`
`print("clues_left")`
A.It will print the word 'clues_left' instead of the number 6.
B.It will print the number 6, which is correct.
C.It will cause an error because of the underscore.
D.The variable should have been named `clues`.
Challenging
You want to see a player's name and their score, each on a new line. Which set of commands will do this?
`player_name = "Zoe"`
`score = 150`
A.print("player_name, score")
B.print(player_name)
print(score)
C.print(player_name, score)
D.print("Zoe, 150")
Challenging
Look at this code block. Which line will cause an error?
`1: treasure_map = "Found"`
`2: print("Checking status...")`
`3: print(treasure_map)`
`4: print(Status Report)`
A.Line 1
B.Line 2
C.Line 4
D.Line 3
Want to practice and check your answers?
Sign up to access all questions with instant feedback, explanations, and progress tracking.
Start Practicing Free