Python Learning – Day 2: Operators and Real-Life Calculations

Python Learning – Day 2: Operators and Real-Life Calculations

Introduction

Welcome to Day 2 of my Python learning journey.
In this lesson, I learned how Python performs mathematical calculations using operators.

Operators are very important in programming because almost every real-world application involves calculations such as bills, salary, discounts, and expenses.


📚 Topics Covered in Day 2

In this lesson, I learned:

  • What are operators in Python
  • Arithmetic operators
  • How Python performs calculations
  • Real-life examples like shopping bills and discounts

🧮 What Are Operators in Python?

Operators are symbols that perform operations on values and variables.

Python operators help us to:

  • Add numbers
  • Subtract values
  • Multiply quantities
  • Divide amounts
  • Find remainders

🔢 Arithmetic Operators in Python

OperatorPurposeExample
+Addition10 + 5
-Subtraction10 – 5
*Multiplication10 * 5
/Division10 / 5
%Modulus (remainder)10 % 3

🏪 Real-Life Example: Shopping Bill

Let’s calculate the total cost of buying rice.

Python Code Example:

rice_price = 60
quantity = 3

total_price = rice_price * quantity
print("Total price =", total_price)

Output:

Total price = 180

This example is similar to calculating a bill in a grocery store.


🏷️ Discount Calculation Example

Now let’s apply a discount to the total price.

Python Code:

rice_price = 60
quantity = 3
discount = 5  # percent

total_price = rice_price * quantity
final_price = total_price - (total_price * discount / 100)

print("Rice price =", rice_price)
print("Quantity =", quantity)
print("Total price =", total_price)
print("Discount =", discount, "%")
print("Final price after discount =", final_price)

Output:

Rice price = 60
Quantity = 3
Total price = 180
Discount = 5 %
Final price after discount = 171.0

🔍 Modulus Operator (%) – Real-Life Meaning

The modulus operator % returns the remainder after division.

Example:

print(10 % 3)

Output:

1

Real-Life Use Case:

If 10 items are divided among 3 people, 1 item will remain.


🌍 Why Operators Are Important?

Operators are used everywhere in real-world applications:

  • Shopping and billing systems
  • Salary calculation
  • Expense tracking
  • Banking applications

Without operators, programming would not be possible.


✅ What I Learned Today

  • How Python performs calculations
  • How to use arithmetic operators
  • How to calculate bills and discounts
  • How Python helps in real-life problem solving

This lesson helped me understand how Python works like a smart calculator.


🔜 Next Lesson (Day 3)

In Day 3, I will learn about:

  • Strings in Python
  • Taking user input using input()
  • Creating simple interactive programs

📢 Final Note

This Python learning series is designed for beginners.
Anyone who wants to learn Python step by step can follow these posts.

Thank you for reading 🚀

One thought on “Python Learning – Day 2: Operators and Real-Life Calculations

Leave a Reply to unlocker Cancel reply

Your email address will not be published. Required fields are marked *