Variables & Assignments
This page will provide homework for the variables and assigmnets lesson.
Variables & Assignment Homework
Description:
- In this homework hack, you will practice creating and using variables. You’ll define variables to store your name and age, reassign values, and answer interactive questions to test your understanding. This activity will help you master the basics of variables and how they work in programming.
🏠 Variables Quest Homework
Objective: Practice creating, manipulating, and combining strings in Python.
Instructions
Complete each challenge by filling in the missing code. Use the examples as a guide, but make sure to write your own values or logic.
Challenge 1: Creating a Life Profile with Variables
# Part 1
## Personal info
my_name = ___ # Fill in your name
my_age = ___ # Fill in your age
my_city = ___ # Fill in the city where you live
# Part 2
## Preferences
favorite_color = ___ # Your favorite color
favorite_food = ___ # Your favorite food
favorite_movie = ___ # Your favorite movie
favorite_song = ___ # Your favorite song
# Part 3
# Reassign some variables
favorite_food = ___
my_city = ___
has_pet = ___
# Part 5: Print Your Life Profile
Print all your variables so your “Life Profile” is displayed:
print("Name:", my_name)
print("Age:", my_age)
print("City:", my_city)
print("Favorite color:", favorite_color)
print("Favorite food:", favorite_food)
print("Favorite movie:", favorite_movie)
print("Favorite song:", favorite_song)
print("Student?", is_student)
print("Has pet?", has_pet)
print("Online?", is_online)
print("Likes music?", likes_music)
Task 2
Creative Challenge
Your task: Create a “story” or “profile” using ONLY variables and assignments.
Instructions:
-
Create at least 8 variables to describe a character or yourself.
Examples:
name
,age
,favorite_food
,hobby
,number_of_pets
,mood
,favorite_color
,dream_job
-
Assign initial values to all variables.
-
Reassign at least 4 of the variables to new values to simulate changes over time or “events” in the story.
- Use print statements to write a story or profile that is at least 5 sentences long.
Each sentence should include at least one variable.
Example:“Tanay (‘age’ 17) loves pizza and plays tennis (‘hobby’) every weekend. Today, Tanay is happy because he ate his (‘favoirite_food’).”
- Optional: Add extra variables to make your story longer and more creative.
You can also create “day 2”, “day 3”, etc., by reassigning variables and printing new sentences.
Goal:
- Show creativity while practicing:
- Variable creation
- Variable reassignment
- Using variables in print statements
- Experiment with assigment and reassigment to update variables