← Back to course
Code Crew G4 / Week 01 / Monday
1/6
Week 01 Β· Values and print

Monday

print shows a message
// Real Python, one line at a time
⏱ about 15 min

Monday: print shows a message

The crew has a new home: Beacon Station, high above the clouds. Rocket taps the big screen in the control room. "Let's make it say hello to everyone!" he says.

He types a line of real Python, but the screen shows an error. Raven leans in. "What do you notice about the words?" she asks. Rocket looks closer. Some words have quote marks, and some do not.

Nova hovers beside them, her cyan lights glowing. "Would you like a hint? Python needs to know where a message starts and where it stops."

Your first real Python

Last year you wrote pseudocode. This year you will read and write real Python.

Python runs a program one line at a time, from the top to the bottom.

The print command shows something on the screen. Here is a program with two lines.

print("Hello, crew!")
print("Welcome to Beacon Station")
The screen shows
Hello, crew!
Welcome to Beacon Station
  • Text inside quote marks is called a string.
  • The quote marks tell Python where the string starts and stops.
  • The quote marks do not show on the screen.
  • Each print starts a new line on the screen.
This line runs: print("Launch at noon"). What words show on the screen?
WHY THIS EXERCISEprint shows the string itself. The quote marks are only there to tell Python where it starts and stops.
Line of PythonDoes the string have a quote mark at both ends?
print("Ready")?
print("Dock 3)?
print("All clear")?
print(Hatch open")?
WHY THIS EXERCISEA missing quote mark is one of the most common bugs. Spotting it fast saves a lot of time.
PUT THE LINES IN ORDER SO THE SCREEN COUNTS DOWN: THREE, TWO, ONE, LIFTOFF!
  • ?print("One")
  • ?print("Two")
  • ?print("Liftoff!")
  • ?print("Three")
WHY THIS EXERCISEThe order of the lines is the order of the output. That is called a sequence.
Try it
Read each line of today's program out loud, like Python would.
Say only the words inside the quote marks.

Practice lab: read the print lines

print("Dock 4 is open")
print("Crew of 3")
print("Bye for now")
What does line 1 show on the screen?
What does line 2 show on the screen?
How many lines show on the screen?
SPOT THE RIGHT LINE
  • Read the question.
  • Tap your answer.
Which line shows Hello with no bug?
In the program above, which line runs first?
How many quote marks does one string need?
StatementTrue or false?
Python runs the bottom line first.?
The quote marks show on the screen.?
Each print starts a new line.?
print("7") shows 7 on the screen.?
WHY THIS EXERCISEThese four facts let you predict the output of any print program.
This line runs: print("Go, Nova!"). What words show on the screen?
WHY THIS EXERCISEEverything inside the quote marks is part of the string, so print shows all of it.

Great start, Crew Engineer! You read your first real Python today. Tomorrow you will give a value a name, so you can use it again and again.