newtum

Our Social Network

PYTHON ARITHMETIC OPERATORS: A COMPLETE GUIDE FOR BEGINNERS

Python Arithmetic Operators: A Complete Guide for Beginners

You’ve already learned how to use the print() and input() functions in Python. If you're still unsure, go back and review the previous sessions. Mastering these basics is crucial because we’re now stepping into the heart of programming — mathematics.

Wait, did that scare you? Don’t worry! You don’t need to be a math wizard. Python makes math easy and approachable. In this session, we’ll learn about Python Arithmetic Operators, not just the basic ones, but also powerful operators like floor division, modulus, and exponentiation.

Let’s dive in!

Why Math is Important in Programming

Every great program has one thing in common — it relies heavily on logic and mathematical operations. Whether it's game development, finance, or machine learning, math is at the core of coding. Luckily, Python gives us a rich set of arithmetic operators to work with numbers effortlessly.

Python supports the following arithmetic operators:

  • + Addition
  • - Subtraction
  • * Multiplication
  • / Division
  • // Floor Division
  • % Modulus
  • ** Exponentiation

Let’s go through each of them with simple, real-world examples.

Floor Division Operator (//)

Imagine you have 11 balls and you want to distribute them equally among 4 friends. If we do 11 ÷ 4, the result is 2.75. But can you give 0.75 of a ball to a friend? Of course not!

So what you really want is only the whole number part of the division — the quotient without the decimal. This is done using the floor division operator (//).

Example:

balls = 11
friends = 4
ball_distributed = balls // friends
print("Balls given to each friend:",ball_distributed)

This gives:

Balls given to each friend: 2

Floor division simply discards the decimal part and returns the integer.

Modulus Operator (%)

After distributing the balls equally, you may want to know how many balls are left. This is where the modulus operator % comes in.

It returns the remainder when one number is divided by another.

Let’s extend the program:

balls = 11
friends = 4
ball_distributed = balls // friends
ball_remaining = balls % friends
print("Balls given to each friend:",ball_distributed)
print("Balls remaining with us:", ball_remaining)

Output:

Balls given to each friend: 2
Balls remaining with us: 3

Remember:

  • // → Gives quotient
  • % → Gives remainder

Exponentiation Operator (**)

Want to calculate powers like 4³ (4 raised to 3)? Python makes it easy with the exponentiation operator **.

Example

x = 4 ** 3
print("4 raised to power 3 is:", x)

Output:

4 raised to power 3 is: 64

Simple and powerful!

Sample Code

1a = 15
2b = 4
3print("Addition:", a + b)
4print("Subtraction:", a - b)
5print("Multiplication:", a * b)
6print("Division:", a / b)
7print("Floor Division:", a // b)
8print("Modulus:", a % b)
9print("Exponentiation:", a ** b)

Code Explanation

  • a + b → Adds two numbers
  • a - b → Subtracts b from a
  • a * b → Multiplies a and b
  • a / b → Performs normal division (returns float)
  • a // b → Floor division (removes decimal)
  • a % b → Returns the remainder
  • a ** b → Raises a to the power of b

This code showcases how versatile Python's arithmetic operators are and how they can be applied to almost any numeric operation.

Output

Addition: 19
Subtraction: 11
Multiplication: 60
Division: 3.75
Floor Division: 3
Modulus: 3
Exponentiation: 50625

Watch It on YouTube

Want to see these operations live in action with examples? Click here to watch the full video on YouTube →

Final Thoughts

Python provides all the basic and advanced arithmetic operators you need to build powerful logic in your programs. You now understand how to use floor division, modulus, and exponentiation — tools you’ll use repeatedly in real-world applications.

Keep practicing. These operators form the building blocks for loops, conditions, and data processing!

Python's math operators are not just symbols; they’re building blocks of powerful programs.

— Manoj Kolhe

More Articles

Ready to Explore the Future of Technology?

Unlock the tools and insights you need to thrive on social media with Newtum. Join our community for expert tips, trending strategies, and resources that empower you to stand out and succeed.

Newtum

Newtum is an emerging online academy offering a wide range of high-end technical courses for people of all ages. We offer courses based on the latest demands and future of the IT industry.

© Newtum, Inc. All Rights Reserved.