Printing a number & Strings in Python Programming

Hey there, future Python pro!
In our last adventure we learned how to store information using variables like name = "Alice" and age = "25". Today we are going to learn those variables are actually doing something fun ! We’ll learn how to:

1. Do math with python
2. Mix words and numbers together
3. Fix common mistakes everyone makes
Ready? let’s jump in!


1. Math in python is your new best friend

Remember calculator struggle? Python solves that! try this in your code:

# Basic math
print(2 + 3)   # Adds → 5
print(10 - 4)  # Subtracts → 6
print(3 * 5)   # Multiplies → 15
print(10 / 2)  # Divides → 5.0 (gives decimal!)

# Bonus math tricks
print(10 // 3) # How many whole 3s fit in 10? → 3
print(10 % 3)  # What's left over? → 1 (because 3x3=9, remainder 1)
print(2 ** 3)  # 2 to the power of 3 → 8

Real life example:
Let’s calculate pizza cost for a party:

pizza_price = 12.99
friends = 5
total = pizza_price * friends
print("We need to pay:", total)  # Shows $64.95

2. Mixing words and numbers like a smoothie

Want to say “Hello, Alice! You’re 25 years old.”? Here’s how:

name = "Alice"
age = 25

# Method 1: Using commas
print("Hello,", name, "! You're", age, "years old.")

# Method 2: F-strings (magic!)
print(f"Hello, {name}! You're {age} years old.")  # Cleaner!

F-strings are your friend! Just add f before the quotes and wrap variables in { }.

3. Oops! fixing common mistakes

We all make these – here’s how to fix them:

Mistake 1: Forgetting quotes

# Wrong
name = Alice  # Python thinks Alice is a variable

# Right
name = "Alice"  # Quotes make it text

Mistake 2: Math with wrong types

# Wrong
print("My age is: " + 25)  # Can't add text + number

# Right
print("My age is: " + str(25))  # Convert number to text first
# OR better:
print(f"My age is: {25}")

Let’s Build Something!

Party Calculator Program:
# Inputs
guests = 10
pizza_per_person = 2.5
cost_per_pizza = 10

# Calculations
total_pizzas = guests * pizza_per_person
total_cost = total_pizzas * cost_per_pizza

# Output
print(f""""
PARTY PLANNER:
Guests: {guests}
Pizzas needed: {total_pizzas}
Total cost: ${total_cost}
""")

Try changing the numbers and see what happens!

Quick Tip When You Get Stuck

See red error messages? Don’t panic! They’re like GPS directions:

1.Read the last line of the error

2.Check the line number it mentions

3.Look for missing commas, quotes, or wrong symbols

Most errors are just tiny typos – even experts make them daily!

What’s Next?

In our next post, we’ll learn how to make Python make decisions for us using “if statements” (like telling you if you passed a test).

Try playing with today’s code – break it, fix it, make it yours! Remember, every coder started right where you are now.

Found this helpful? Have a question? Drop a comment below! Let’s learn together.

Happy coding! 🚀

P.S. Here’s your reward for reading this far:

print("🐍 You're awesome! " * 3)

Python Tutorial: Python Data Types and Variables for Beginners | How Many Data Types in Python

Leave a Comment