Lesson 4. Common mistake to debug. If Python gives an error, check quotes and parentheses first. A frequent beginner mistake is guessing the length instead of using len(callsign), or building the report but forgetting to print it. Code example. # Prefer this: callsign length = len(callsign) # Not this: callsign length = 12 Micro Trial Steps. Step 1. Tune the text channel. Concept. string assignment. Create callsign and sector code as quoted text before measuring or formatting anything....
Full Transcript
Lesson 4. Common mistake to debug. If Python gives an error, check quotes and parentheses first. A frequent beginner mistake is guessing the length instead of using len(callsign), or building the report but forgetting to print it. Code example. # Prefer this: callsign length = len(callsign) # Not this: callsign length = 12 Micro Trial Steps. Step 1. Tune the text channel. Concept. string assignment. Create callsign and sector code as quoted text before measuring or formatting anything. Checkpoint. callsign and sector code both exist as strings. Step 2. Measure the callsign. Concept. len() call. Use len(callsign) instead of guessing the character count. Checkpoint. callsign length stores the measured length from len(). Step 3. Assemble the transmission. Concept. f string report. Use an f string to place the variables inside one comms report message. Checkpoint. comms report is a string that includes the callsign, sector, and measured length. Step 4. Broadcast the report. Concept. printed output. Print comms report so the academy console can inspect the message. Checkpoint. The console output begins with Saber report:. Do This In Order. Practice step 1. Type callsign = "Vader's Fist" so Python stores the channel name as text. Practice step 2. Type sector code = "DS 01" so the report has a second string value. Practice step 3. Type callsign length = len(callsign) so Python measures the string for you.
Lesson 4. Common mistake to debug. If Python gives an error, check quotes and parentheses first. A frequent beginner mistake is guessing the length instead of using len(callsign), or building the report but forgetting to print it. Code example. # Prefer this: callsign length = len(callsign) # Not this: callsign length = 12 Micro Trial Steps. Step 1. Tune the text channel. Concept. string assignment. Create callsign and sector code as quoted text before measuring or formatting anything....