Chapter 6: Counting Up from Zero

Brian eagerly accepted the new mission displayed on his phone. Zero SP felt uncomfortable now that he knew what they could buy.

[Mission: Keeping Score]

[Objective: Create a simple Python script. Initialize a 'score' variable at 0. Allow the user to press Enter to increment the score by 1. Display the updated score each time. The program should continue until the user types 'quit'.]

[Rewards: +10 SP, +1 Programming Skill Point (Python - Novice Level 4), [Simple 8x8 Icon Set (10 Icons)] unlocked.]

[Failure Penalty: Loss of 2 SP (Applied if Host gives up or produces non-functional code after 3 attempts).]

[Utilize knowledge from 'Python Basics' module. System guidance available.]

Ten SP! That was double the last mission reward. And another asset pack. The objective sounded more complex – incrementing, looping until told to stop. This felt less like printing text and more like a tiny piece of actual program logic.

"Okay, System," Brian murmured, cracking his knuckles. "Guide me."

[Guidance Initiated.]

[Step 1: Initialize the score. Remember variable assignment from the module?]

score = 0

Easy enough. He typed that into a new Notepad file, saving it as score_keeper.py.

[Step 2: Create a loop that continues indefinitely until broken. The while True: loop is suitable.]

[Code within this loop will repeat.]

while True:

# Code to repeat goes here, indented

Indentation? The System briefly explained Python's use of whitespace for structure. Brian carefully typed while True: and indented the next line with four spaces.

[Step 3: Inside the loop, display the current score. Use print() and remember string conversion for numbers if needed.]

print("Current Score: " + str(score))

[The str() function converts the integer score into a string so it can be joined with other text.]

Ah, data types! He remembered that from the module. You couldn't just add text and numbers directly. He typed the print line, making sure it was indented under the while True:.

[Step 4: Get user input to proceed or quit. Use input().]

command = input("Press Enter to increase score, or type 'quit' to exit: ")

This line also went inside the loop, indented.

[Step 5: Check the user's input. If they typed 'quit', break the loop. Use an if statement.]

if command == "quit":

break # Exit the loop

Conditional logic! This was new but felt intuitive. He typed the if statement and the break command, ensuring the break was indented under the if.

[Step 6: If the command wasn't 'quit', increment the score. Use the += operator for shorthand.]

else:

score += 1 # Increase score by 1

This else block followed the if block, still inside the main while loop. score += 1 was cleaner than score = score + 1. He added it.

[Final Code Structure Check... Looks correct. Save and execute python score_keeper.py.]

Brian saved the file, his palms slightly sweaty. This was multiple lines, loops, conditions... He switched to the Command Prompt and typed python score_keeper.py, hitting Enter.

The output appeared:

Current Score: 0

Press Enter to increase score, or type 'quit' to exit:

He pressed Enter.

Current Score: 1

Press Enter to increase score, or type 'quit' to exit:

He pressed Enter again.

Current Score: 2

Press Enter to increase score, or type 'quit' to exit:

It worked! Each press increased the score. He hit Enter a few more times, watching the number climb. Then, he typed quit and pressed Enter. The program stopped, returning him to the command line prompt. He'd done it!

His phone lit up.

[Mission: Keeping Score - Complete!]

[Calculating Rewards...]

[+10 System Points awarded.]

[+1 Programming Skill Point allocated (Python - Novice Level 4).]

[Item Unlocked: [Simple 8x8 Icon Set (10 Icons)] - Available in Store Inventory.]

[Host Status Update:]

[Name: Brian]

[Skills: Programming (Python - Novice 4/10)]

[System Points (SP): 10]

Ten SP banked. Level 4 programmer (Novice, but still!). He felt a genuine thrill. This wasn't just following instructions anymore; he was starting to understand how to make the computer do things. He glanced at the newly unlocked icon set in the store preview – tiny pixelated images. Useless on their own, but maybe... just maybe... they were the first visual pieces of a real game.