Print("Launch ready")Find the repair
print("Launch ready")In a fresh program, Print is undefined. Use the lowercase built-in name.
CODE LAB 01 / FIRST CONTACT
print("Hello")Small messages.Program a greeting. Give your rover a name. Turn a few words into a mission story.
让代码说话:从输出文字,到变量、故事和自己的小作品。

print("Hello")› Hello01 / PREPARE THE WORKSPACE
A program is a set of instructions. In this lab, you will write Python instructions that send messages to the output area, often called the console.
Build a personalized mission postcard using text, a number, variables and an f-string. Add a helpful comment, and remove or disable a temporary test message.
网页上的互动是概念演示;完整Python代码请在Trinket中运行。 / The guided models here explain specific ideas; Trinket runs your Python programs.
| Action | Windows / ChromeOS | Mac |
|---|---|---|
| Copy selected text | Ctrl + C | Command + C |
| Paste copied text | Ctrl + V | Command + V |
| Undo an edit | Ctrl + Z | Command + Z |
| Select all in the focused editor | Ctrl + A | Command + A |
| Save in many code editors | Ctrl + S | Command + S |
Shortcuts depend on the app and which area has focus. In a browser, Save may save the web page and New may open a browser window. Use Trinket’s own controls for saving, creating activities and running; do not assume an F5 shortcut runs your code.
Session A: chapters 1–5. Session B: chapters 6–9. Session C: projects and review. Allow about 45–60 minutes each and choose extra challenges as needed.
02 / MAKE YOUR FIRST MESSAGE
print() is a built-in Python function. For our first instruction, put a message between matching quotes, then place that string inside the parentheses.
print("Hello")OUTPUT / 输出
Hello
printThe function nameLowercase matters.( )The call parenthesesEnclose the argument."Hello"A stringText inside matching quotes.The quotes mark the boundaries of the string in the code. print() displays the text without those surrounding delimiters. It also ends with a newline unless you tell it otherwise; we will use its default behavior here.
print("Mission Control")
print("Rover online.")
print("Ready to explore!")Mission Control Rover online. Ready to explore!
Now change the second message and rerun. Programs execute these statements in order, from top to bottom.
GUIDED MODEL / MESSAGE PREVIEW
PREPARED CODE
print("Rover online.")EXPECTED OUTPUT
Rover online.
This prepares a print statement; copy it into Trinket to execute Python.
QUICK CHECK / 想一想
03 / LEAVE NOTES. FIND BUGS.
A comment is a note for people reading the code. Outside a string, # starts a comment that continues to the end of that physical line. Python does not execute that comment as a statement.
Use comments to explain a purpose or temporarily disable a complete test line. Their color depends on the editor; no particular color is required.

# Announce the mission
print("Ready for launch")
# print("Testing speaker...")
print("Crew check complete") # Final statusOUTPUT / 输出
Ready for launch Crew check complete
The test message is still in the file, but its line is commented out. Once it is no longer useful, you may delete it. Commenting out code helps isolate a problem, but does not by itself repair the underlying mistake.
print("Dock #7") # The # inside quotes is textDock #7
GUIDED MODEL / COMMENT SWITCH
EXPECTED OUTPUT
This model switches one prepared example. It is not a general Python runner.
Print("Launch ready")print("Launch ready")In a fresh program, Print is undefined. Use the lowercase built-in name.
print("Launch ready"print("Launch ready")The opening parenthesis needs its closing partner.
QUICK CHECK / 想一想
04 / QUOTES & ESCAPE SEQUENCES
Single quotes and double quotes can both delimit a string. Choose a matching pair. If the text contains an apostrophe, double quotes are often the simplest outer pair.
print("The rover's lights are on.")
print('The screen says "Welcome".')OUTPUT / 输出
The rover's lights are on. The screen says "Welcome".
print('The rover's lights are on.')The apostrophe after rover closes this single-quoted string too early. Python then encounters characters where the remaining syntax does not make sense. This is a string-syntax problem, not a limit of print().
Another solution is an escape sequence: a backslash changes how the next character is interpreted inside the string.
print('The rover\'s lights are on.')
print("The screen says \"Welcome\".")OUTPUT / 输出
The rover's lights are on. The screen says "Welcome".
\'Include an apostrophe in a single-quoted string.\"Include a double quote in a double-quoted string.\\Include one literal backslash.\nStart a new output line.print("Folder: missions\\day1")Folder: missions\day1
GUIDED MODEL / QUOTE STUDIO
EXPECTED OUTPUT
Notice which quote characters need a backslash. The output text stays the same.
QUICK CHECK / 想一想
05 / GIVE TEXT SOME SPACE
You can use separate print() calls, place \n inside a string, or write a triple-quoted string across multiple source lines.
print("Earth\nMoon\nMars")OUTPUT / 输出
Earth Moon Mars
The code contains a backslash and a lowercase n; the resulting string contains a newline character. Use \n\n to leave an empty line between two pieces of text.
print("Launch deck\n\nObservation deck")Launch deck Observation deck
mission_note = """Open the hatch.
Check the stars.
Begin the journey."""
print(mission_note)OUTPUT / 输出
Open the hatch. Check the stars. Begin the journey.
Three opening double quotes match three closing double quotes. Triple single quotes also work. These are string delimiters, not escape sequences, and they do not automatically substitute variable names.
A newline immediately after the opening triple quotes becomes a first blank line. Spaces typed before a text line also become part of the string. Start the first word right after the opening quotes when you want no first blank line, as in this example.
Paper-based printing equipment had to advance to another line as well as position the print head. The old ASCII standard distinguishes line feed—moving to the next printing line—from carriage return—moving to the first position on the same line. The names survived in computer text systems. Python’s \n represents a newline in a string.
History reference: RFC 20, control-character definitions.
QUICK CHECK / 想一想
06 / NAMES THAT REMEMBER VALUES
A variable name lets you refer to a value. In rover_name = "Pip", Python first evaluates the value on the right and binds the name on the left to that value. The equals sign performs assignment.
rover_name→"Pip"rover_name = "Pip"
print(rover_name)
print("rover_name")Pip rover_name
print(rover_name) looks up the name’s value. print("rover_name") prints those literal letters. Use a variable only after assigning it; otherwise a missing name can produce NameError.
rover_name = "Pip"
print(rover_name)
rover_name = "Nova"
print(rover_name)Pip Nova
GUIDED MODEL / STEP THROUGH ASSIGNMENT
rover_name = "Pip"print(rover_name)rover_name = "Nova"print(rover_name)CURRENT BINDING
No value assigned yet
OUTPUT SO FAR
0 / 4 lines explored
The arrow is a way to think about a Python name referring to an object. A Python variable is not necessarily one fixed CPU register or a literal labeled storage box. Changing a name’s binding also does not erase text already printed.
QUICK CHECK / 想一想
07 / SAME DISPLAY, DIFFERENT TYPE
7 and "7"7 is an integer, with type int. "7" is a string, with type str. Both can look the same when printed, so appearance alone does not tell you the type.
crew_count = 7
dock_code = "7"
print(crew_count)
print(dock_code)
print(type(crew_count))
print(type(dock_code))OUTPUT / 输出
7 7 <class 'int'> <class 'str'>
type(value) gives information about the object’s type. In a script, use print(type(value)) to display it. A Python interactive shell may display the value of a bare expression automatically.
GUIDED MODEL / TYPE LENS
message = ""
print(type(message))<class 'str'>
An empty string "" is still an assigned value. It is useful when you want text with zero characters; it does not mean “unassigned.”
temperature = 18.5
ready = True
print(type(temperature))
print(type(ready))OUTPUT / 输出
<class 'float'> <class 'bool'>
A float can represent a value with a fractional part; bool represents True or False. Lists hold collections. Today’s projects mainly need strings and integers.
QUICK CHECK / 想一想
08 / CHOOSE USEFUL NAMES
class or for.crew and Crew are different.snake_case: crew_count.crewCount is camelCase. It can be valid Python, but is not the style used in this lesson.x9 tells us little.print or type with your own values.mission_name = "Moon Garden"
crew_count = 7
rover_2 = "Nova"
print(mission_name)
print(crew_count)
print(rover_2)OUTPUT / 输出
Moon Garden 7 Nova
GUIDED MODEL / NAME CHECKER
This beginner checker uses English letters, digits and underscores. Python also supports many non-English letters in names. Style advice is separate from syntax validity.
QUICK CHECK / 想一想
09 / BUILD MESSAGES WITH F-STRINGS
An f-string starts with f before its opening quote. Python evaluates expressions in { } when it creates that string and inserts their values into the text. It is a formatting feature, not a backslash escape.
rover_name = "Nova"
destination = "Europa"
print(f"{rover_name} is heading to {destination}.")OUTPUT / 输出
Nova is heading to Europa.
fEnable formattingBefore the quote.{rover_name}Look up a valueThe expression goes in braces..Keep literal textText outside braces stays text.rover_name = "Nova"
print("Hello, {rover_name}!")
print(f"Hello, {rover_name}!")Hello, {rover_name}!
Hello, Nova!
F-strings can insert an integer or evaluate a simple expression too; they do not require every expression to be a previously assigned variable.
crew_count = 7
print(f"Crew aboard: {crew_count}")
print(f"Extra seats needed: {crew_count + 2}")Crew aboard: 7 Extra seats needed: 9
GUIDED MODEL / MISSION CARD MAKER
EXPECTED OUTPUT
This prepares a fixed example from these fields. Run the copied program in Trinket.
captain = "Mika"
destination = "Moon Garden"
mission_card = f"""MISSION CARD
Captain: {captain}
Destination: {destination}
Status: ready"""
print(mission_card)OUTPUT / 输出
MISSION CARD Captain: Mika Destination: Moon Garden Status: ready
Triple quotes preserve the source line breaks; the f prefix enables the expressions. These are two independent features. To print a string variable unchanged, print(mission_card) is enough.
station = "Aurora"
report_title = f"Message from {station}"
print(report_title)
station = "Comet"
print(report_title)
report_title = f"Message from {station}"
print(report_title)OUTPUT / 输出
Message from Aurora Message from Aurora Message from Comet
report_title keeps the text that was created earlier. Reassigning station does not go back and change that existing string. Rebuild the title to include the new station value.
print(f"Write {{name}} as a placeholder.")OUTPUT / 输出
Write {name} as a placeholder.
Inside an f-string, doubled braces {{ and }} produce literal braces.
QUICK CHECK / 想一想
10 / THE PROJECT STUDIO

Start with one small project, then choose another. The final mission postcard combines the key ideas. These starters are examples to change, not scripts you must copy word for word.
Use a nickname in a two-line introduction. Change both the nickname and the welcome message.
Check: Two lines; the nickname is inserted from a variable.
Invent a short piece of advice from a fictional character. Print visible quotation marks and an attribution.
Check: The quotation marks appear in the output; the outer code quotes do not.
Print a status, assign a different value to the same variable, then print a second status.
Check: The first message keeps its old result, and the second uses the new value.
Write three original lines and store them in a triple-quoted string. Optional: try the 5–7–5 syllable pattern of a beginner English haiku-style exercise. Python checks the code, not your poem’s syllables.
Check: Three intentional lines, without an accidental first blank line.
Ask a partner for a pilot, place, object, companion and number. Assign the choices, then create a new three-line story with an f-string. No input() is needed yet.
Check: At least four text values and one integer appear in the story.
Combine two existing variables into a new label. Then change one value and rebuild the label. Explain why an already-created string does not update by itself.
Check: The label uses existing variables rather than retyping the station name.
Replace the invalid or unclear names in the repair puzzle below with clear snake_case names. Update every use of each renamed variable.
Check: The code runs, the names describe their contents, and the report is readable.
Design a new six-line picture from keyboard characters. Store it in a triple-quoted string and add an f-string heading. Keep spacing aligned.
Check: A heading and an aligned text picture, made from your own design.
Combine comments, a string variable, an integer and a multiline f-string. Comment out a temporary test message before your final run.
Check: One clear postcard; no extra debug message; new values change the output after rerunning.
2captain = "Mika"
x = 7
MissionCOLOR = "teal"
print(f"Captain {2captain}: {x} crew, {MissionCOLOR} flag.")One name is invalid; two could be clearer or more consistent. Write your repair in the workspace. The starter for this task shows one possible solution.
YOUR WORKBENCH / 草稿区
This is a draft editor, not a Python interpreter. Project drafts remain in this tab’s memory when you switch projects; copy or download them before leaving or refreshing. They are not sent to student accounts or Trinket automatically.
This belongs to the original starter. Your edited program may produce different output; run it in Trinket to find out.
11 / MISSION DEBRIEF
Matching quotes delimit strings. Escapes can include quotes, backslashes and newlines. Triple quotes can span source lines.
Names refer to values. Reassignment changes the binding. Types distinguish text from integers even when they print alike.
F-strings evaluate expressions in braces when created. They can be multiline, but triple quotes do not require an f prefix.
Use clear names, explain useful intentions in comments, predict results and fix one likely issue at a time.
Feedback is shown here only. This checks concepts, not whether your own Python program runs.
This expanded Lesson 1 is an original workshop based on the programming topics visible in the supplied reference scans. Wording, story world, program examples, activities, illustrations and page composition are newly created. No scanned pages or book artwork are published.
Recommended sequence: session A—setup, output, comments, debugging, quote handling and multiline text; session B—assignment, reassignment, types, naming and f-strings; session C—choose several projects, finish the mission postcard and share. The nine projects include introduction, quoted dialogue, changing state, poetry, word substitution, reuse, naming repair, text art and an integrated final program. Use extra projects for later practice rather than rushing every concept.
The two very blurred scanned spreads cannot be read reliably. The lesson covers the legible themes without inventing their unreadable details. Clarifications include: comments can follow code but a hash inside a string is text; variable names may contain later digits; Python names are not assumed to map to CPU registers; an empty string is assigned data; f prefixes and triple-quote delimiters are distinct; a built f-string does not update retrospectively. F-strings require a compatible Python 3 environment (introduced in Python 3.6).
The course link is used as supplied. The signed-in Trinket course has not been edited. The lesson’s guided models are not general Python execution, and typing here does not submit work. Choose a Python 3 workspace for the f-string activities.