Programming Lessons
Programming Fundamentals | 3.1 | 3.2 | 3.3 | 3.12 |
3.1 Variables & Assignments hacks - Python
Apply your understanding of Variables & Assignments with these Python hacks
🐷 Peppa Maze Variables & Assignments Hacks (Python)
Welcome to the Peppa Maze hacks! These challenges will test your understanding of variables, assignments, and logic in Python. Read each task, then write or modify code to solve it.
Hack 1: Python - Variable Assignment, Naming, and Operators
Create variables for Peppa’s name, score, and level using good Python naming conventions. Assign initial values, then use operators to update score (add 10) and level (multiply by 2). Print all results.
# Write your code here
# Create variables for Peppa's name, score, and level
# Use operators to update score and level
Hack 2: Python - Variable Declaration, Assignment, and Operators
Declare variables for Peppa and George’s scores using good Python naming conventions. Assign initial values, then use operators to update both scores (e.g., Peppa gets 15 points, George loses 5 points). Print both scores.
# Write your code here
# Declare variables for Peppa and George's scores
# Use operators to update both scores
Hack 3: Python - Multiple Assignment and Math Operators
Peppa and George both start at level 1. Use Python’s multiple assignment feature to assign both their levels to 5 in one line. Then, calculate a combined score by multiplying their levels together and multiplying by 10. Print all results.
# Write your code here
# peppa_level = 1
# george_level = 1
# Assign both levels to 5 in one line using multiple assignment
# combined_score = peppa_level * george_level * 10
# Print all results