0Pricing
Learn AI with Python · Lesson

Basic Arithmetic and Operators

Explore Python's arithmetic operators and how to perform calculations.

Basic Arithmetic and Operators is a free Learn AI with Python lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Learn AI with Python learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

1

Introduction to Arithmetic and Operators

Operators are symbols that perform specific operations on values or variables. Arithmetic operators are used to perform mathematical calculations.

In this lesson, you’ll learn the basic arithmetic operators in Python.

Basic Arithmetic and Operators — illustration 1

2

Basic Arithmetic Operators

Here are some common arithmetic operators in Python:

  • + : Addition (e.g., 2 + 3 gives 5).
  • - : Subtraction (e.g., 7 - 2 gives 5).
  • * : Multiplication (e.g., 4 * 3 gives 12).
  • / : Division (e.g., 10 / 2 gives 5.0).

3

Examples of Arithmetic Operators

Let’s look at some examples:

# Arithmetic operators in Python
a = 10
b = 5
print(a + b)  # Addition
print(a - b)  # Subtraction
print(a * b)  # Multiplication
print(a / b)  # Division

4

Integer Division and Modulus

Python also provides:

  • //: Integer Division (e.g., 10 // 3 gives 3).
  • %: Modulus (remainder) (e.g., 10 % 3 gives 1).

These operators are useful when you need precise control over division.

# Integer division and modulus
a = 10
b = 3
print(a // b)  # Integer division
print(a % b)   # Modulus

5

Exponentiation

You can raise a number to the power of another using **:

# Exponentiation
result = 2 ** 3
print(result)  # 8

6

Operator Precedence

Python follows the order of operations: 

  • Parentheses (()
  • Exponentiation (**
  • Multiplication, Division, Modulus (*, /, %, //
  • Addition, Subtraction (+, -)

For example:

# Operator precedence
result = 2 + 3 * 4
print(result)  # 14

7

Using Parentheses to Change Precedence

You can use parentheses to change the order of operations:

# Changing precedence with parentheses
result = (2 + 3) * 4
print(result)  # 20

8

Combining Arithmetic with Variables

Arithmetic operations can be combined with variables:

# Combining arithmetic with variables
x = 5
y = 2
z = x ** y + x / y
print(z)

9

10

What Did We Learn?

In this lesson, you learned:

  • The basic arithmetic operators in Python: +, -, *, /.
  • How to use //, %, and ** for integer division, modulus, and exponentiation.
  • The importance of operator precedence and using parentheses to change it.

Great job! Let’s move on to the next topic.

Basic Arithmetic and Operators — illustration 10

Frequently asked questions

Is the “Basic Arithmetic and Operators” lesson free?

Yes — the full text of “Basic Arithmetic and Operators” is free to read here on the web, and the Learn AI with Python course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Learn AI with Python course, upgrade to CoddyKit PRO.

What will I learn in “Basic Arithmetic and Operators”?

Explore Python's arithmetic operators and how to perform calculations. You practise Learn AI with Python with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Learn AI with Python?

No prior experience is required. Learn AI with Python on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Basic Arithmetic and Operators” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Learn AI with Python lesson?

Yes. Every Learn AI with Python lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Variables and Data Types
  2. Input and Output
  3. Basic Arithmetic and Operators
  4. Comments and Code Readability
← Back to Learn AI with Python