Language

Python Basics · Lesson 4 of 56

Operators

Source: 1-Python Basics/1.3-operators.ipynb

Start here — no coding background needed

What you will learn

Do math and compare values — greater than, equal to, etc.

In simple words

Use + - * / like a calculator. Use == to check equality and > < to compare. Result is often True or False.

Think of it like this

Shopping: total price, "is total over budget?", "is discount exactly 10?"

Words to know:

  • == — Checks if two values are equal
  • > — Checks if left side is bigger

Start here if you have never coded. We use everyday examples — no jargon without explanation.

Easy example — try this first

Easy example — run this first. Change values and press Run again.

Python

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference notes (from full bootcamp)

Optional — deeper detail for when you are ready

Deep Dive into Operators

Video Outline:

  1. Introduction to Operators
  2. Arithmetic Operators

- Addition

- Subtraction

- Multiplication

- Division

- Floor Division

- Modulus

- Exponentiation

  1. Comparison Operators

- Equal to

- Not equal to

- Greater than

- Less than

- Greater than or equal to

- Less than or equal to

  1. Logical Operators

- AND

- OR

- NOT

  1. Practical Examples and Common Errors
Reference example
Python
Output
Expected (from notebook):
15
5
50
2.0
2
0
100000

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
2.0

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
4.2

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
4

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Comparison Operators

Reference example
Python
Output
Expected (from notebook):
True

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
True

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
False

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
True

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
False

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
True

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
True

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
True

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Logical Operators

Reference example
Python
Output
Expected (from notebook):
True

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
False

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
False

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
True

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Example HCL
HCL
## Simple Calculator

# Simple calculator
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

# Performing arithmetic operations
addition = num1 + num2
subtraction = num1 - num2
multiplication = num1 * num2
division = num1 / num2
floor_division = num1 // num2
modulus = num1 % num2
exponentiation = num1 ** num2

# Displaying results
print("Addition:", addition)
print("Subtraction:", subtraction)
print("Multiplication:", multiplication)
print("Division:", division)
print("Floor Division:", floor_division)
print("Modulus:", modulus)
print("Exponentiation:", exponentiation)

Browser practice only — full example needs Python on your computer (files, Flask, threads, etc.).

Practice test — try yourself

Write code, press Check. Wrong answer shows the correct code to copy & run.

a=15, b=4. Print sum and product on separate lines (Sum: 19, Product: 60).

Python