Day 2 of my Python challenge was all about variables.
In simple terms,variables are like containers where you can store information (numbers, words, etc.) and use them later in your program.
Here’s the code I wrote today:
first_name = "sanaipei"
last_name = "Lenapunya"
food = "Pilau"
email = "sanaipei@gmail.com"
print(first_name)
print(last_name)
print(f"Hello {first_name} {last_name}")
print(f"I love {food}")
print(f"My email is {email}")
What happened when I ran it?
Each variable (name,food,email) holds a value. Instead of typing the same text multiple times, you just store it once in a variable and reuse it. This makes your code easier to manage and change later.
GitHub update:
I saved my file as day2(variable).py,then used:
git add 'day2(variable).py'
git commit -m "variables in python"
git push
Now my progress is safe on GitHub!
Challenge for you:
Create three variables: favorite_food, favorite_color, and favorite_movie.
Print them out in a sentence (e.g., “My favorite food is …”).
Your turn:
What three variables would you create to describe yourself? Share them in the comments I’d love to read your creative answers!
Top comments (0)