Interview Questions, Answers and Tutorials

Arithmetic Operations

Arithmetic Operations

Hey there young Python enthusiasts!

Are you ready to dive into the exciting world of arithmetic operations using Python? Awesome! Let’s embark on this fun journey together and learn how to perform some cool mathematical tricks using our favorite programming language.

What are Arithmetic Operations?

Arithmetic operations are simply the basic math operations we use every day: addition, subtraction, multiplication, and division. But guess what? We can do these operations in Python too! Python lets us perform these operations quickly and easily, just like a magic wand!

Addition (+):

Imagine you have some candies. If you want to know how many candies you have altogether, you add them up, right? That’s exactly what addition does!

# Let's add two numbers in Python
num1 = 5
num2 = 3
result = num1 + num2
print("5 + 3 =", result)

Subtraction (-):

Now, suppose you shared your candies with your friends and want to know how many you have left. That’s when subtraction comes to the rescue!

# Let's subtract two numbers in Python
num1 = 10
num2 = 4
result = num1 - num2
print("10 - 4 =", result)

Multiplication (*):

Let’s say you want to know how many candies you’ll have if you multiply the number of candies you have by the number of friends you’re sharing with. That’s where multiplication helps!

# Let's multiply two numbers in Python
num1 = 6
num2 = 3
result = num1 * num2
print("6 * 3 =", result)

Division (/):

And finally, if you want to share your candies equally among your friends, you use division!

# Let's divide two numbers in Python
num1 = 20
num2 = 5
result = num1 / num2
print("20 / 5 =", result)

Putting it All Together:

Now, let’s have some fun and mix these operations together!

# Let's mix arithmetic operations in Python
result = (10 + 5) * 2 - 4 / 2
print("(10 + 5) * 2 - 4 / 2 =", result)

And there you have it, young Python learners! You’ve just unlocked the power of arithmetic operations in Python. Now you can perform magical math tricks right from your computer! Keep exploring and practicing, and you’ll become a Python wizard in no time!

Keep coding and have fun! 🚀✨