This assignment lets you practice what we learned in class about variables and conditional statements in Python. You'll write code to create variables, use them to store information, print them out, and then use conditional statements to make decisions based on those values.
What You'll Learn:
- How to create and use variables (strings, numbers, booleans)
- How to print variable values
- How to write if, elif, and else statements to make decisions in your code
Your Task:
Open main.py and follow the 3 steps outlined in the comments. Each step has clear instructions to guide you!
Your coding environment is already set up and ready to go. Everything you need is installed automatically!
Your environment includes:
- Python (ready to run your code)
- Python Test Explorer (to check your work with the beaker icon 🧪 in the sidebar)
- A Python Debugger (to step through code and find bugs)
- Auto-Formatting (your code looks clean when you save)
Once your Codespace is ready:
- Look for the file called
main.pyin the file explorer on the left - Click on it to open it
- In the terminal at the bottom of the screen, type:
python main.py
- Press Enter
- You should see:
Hello, World!
Congratulations! You just ran your first Python program! 🎉
Tests help make sure your code works correctly. You can run tests in two ways:
- In the terminal, type:
pytest
- Press Enter
- You should see that tests passed ✓
To see more details about what each test does:
pytest -v- Click the beaker/flask icon 🧪 in the left sidebar (Testing)
- You'll see a list of all your tests
- Click the
▶️ play button next to a test to run it - Green checkmarks ✓ mean the test passed!
- This is a great way to see which tests pass and which fail
Tip: The Test Explorer automatically discovers new tests when you save your files!
assignment_variables_conditionals/
├── main.py # Your assignment - complete the 3 steps!
├── tests/ # Tests to check if your code works
│ └── test_main.py # Tests for your assignment
├── requirements.txt # Python tools needed
└── README.md # This file (instructions)
- Ask your teacher or classmates
- Try the code and see what happens - It's okay to make mistakes!
- Read error messages carefully - They often tell you what's wrong
- Save your work often (it auto-saves, but you can also press
Ctrl+SorCmd+S) - Run your code frequently to catch mistakes early
- Start small and build up - don't try to write everything at once
- If something doesn't work, try reading the error message - it usually gives you a hint!