• Home
  • Python
    • Introduction to Python
    • Python Developer
    • Expert Python Developer
  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
    • Expert JavaScript Developer
  • React.js
    • Introduction to React
    • React Developer
    • Expert React Developer
  • Linux
    • CyberSecurity - Introduction to Linux
    • CyberSecurity - Linux Administrator
    • CyberSecurity - Expert Linux Administrator
  • Active Directory
    • CyberSecurity - Introduction to Active Directory
    • CyberSecurity - Active Directory Administrator
    • CyberSecurity - Expert Active Directory Administrator
  • Interactive Training
  • Pricing
  • Brainstorm
STEMTrainingGrounds
  • Courses
    • Home
    • Python
      • Introduction to Python
      • Python Developer
      • Expert Python Developer
    • JavaScript
      • Introduction to JavaScript
      • JavaScript Developer
      • Expert JavaScript Developer
    • React
      • Introduction to React
      • React Developer
      • Expert React Developer
    • Linux
      • CyberSecurity - Introduction to Linux
      • CyberSecurity - Linux Administrator
      • CyberSecurity - Expert Linux Administrator
    • Active Directory
      • CyberSecurity - Introduction to Active Directory
      • CyberSecurity - Active Directory Administrator
      • CyberSecurity - Expert Active Directory Administrator
  • Interactive Training
  • Pricing
  • Brainstorm

Quick Links

  • About Us
  • Pricing
  • Brainstorm

Courses

  • Python
    • Introduction to Python
    • Python Developer
    • Expert Python Developer
  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
    • Expert JavaScript Developer
  • React
    • Introduction to React
    • React Developer
    • Expert React Developer
    • Professional Master React Developer
  • Linux
    • CyberSecurity - Introduction to Linux
    • CyberSecurity - Linux Administrator
    • CyberSecurity - Expert Linux Administrator
  • Active Directory
    • CyberSecurity - Introduction to Active Directory
    • CyberSecurity - Active Directory Administrator
    • CyberSecurity - Expert Active Directory Administrator

Newsletter

Subscribe to our monthly newsletter, for a quick update on Python, JavaScript, React news

© 2024 - 2026 STEMTrainingGrounds. All Rights Reserved.

Lesson 3

Lesson 3 of 16

Operators

Lesson Progress: 0%

Code Example

# Add (+)
print(5 + 2)
print(10 + 3)

# Subtract (-)
print(8 - 3)
print(10 - 4)

# Multiply (*)
print(4 * 2)
print(3 * 3)

# Divide (/)
print(8 / 2)
print(10 / 5)

Instructions

▲ ← Click the triangle to hide or reveal instructions.
  • The code editor is below.
  • The left side of the code editor is where you type your input code.
  • The right side of the code editor is where you see the output of your code.
  • Practice by typing the code example above, in the left side of the code editor below.
  • Then click the "Run Code" button, to run the code.
  • You will see the output of your code in the output section.

Python Code Editor

Task Incomplete

Editor Input:

Loading...

Editor Output:

Click "Run Code" to see the output here
  • Python can do math for us, like a calculator.
  • Operators are simply special symbols that can be used to do math.
  • The plus sign + means add.
  • The minus sign - means subtract.
  • The star * means multiply.
  • The slash / means divide.
  • We use print() to show the answer on the screen.
  • print(5 + 2) adds 5 and 2 and shows the answer.
  • print(8 - 3) takes 3 away from 8.
  • print(4 * 2) multiplies 4 and 2.
  • print(8 / 2) divides 8 by 2.
  • Each line does one math problem.
  • Python figures out the answer and prints it for us.

Code Example

print(10 % 3) 

print(8 % 4)

print(7 % 5)

Instructions

▲ ← Click the triangle to hide or reveal instructions.
  • The code editor is below.
  • The left side of the code editor is where you type your input code.
  • The right side of the code editor is where you see the output of your code.
  • Practice by typing the code example above, in the left side of the code editor below.
  • Then click the "Run Code" button, to run the code.
  • You will see the output of your code in the output section.

Python Code Editor

Task Incomplete

Editor Input:

Loading...

Editor Output:

Click "Run Code" to see the output here
  • The % symbol in Python is like a "leftovers" counter for math problems.
  • When you divide two numbers, the answer it gives you is the amount that is left over at the end.
  • For 10 % 3, Python sees that 3 fits into 10 three times, with 1 left over, so the answer is 1.
  • If a number fits perfectly with nothing left over, like 8 % 4, Python will give you a 0.
  • It is a super helpful tool when you want to check if a number is even or odd!

Code Example

number = 7
print(number % 2)
print(number % 2 == 0)
print(number % 2 == 1)  

number = 10
print(number % 2)
print(number % 2 == 0)
print(number % 2 == 1)

Instructions

▲ ← Click the triangle to hide or reveal instructions.
  • The code editor is below.
  • The left side of the code editor is where you type your input code.
  • The right side of the code editor is where you see the output of your code.
  • Practice by typing the code example above, in the left side of the code editor below.
  • Then click the "Run Code" button, to run the code.
  • You will see the output of your code in the output section.

Python Code Editor

Task Incomplete

Editor Input:

Loading...

Editor Output:

Click "Run Code" to see the output here
  • You can use the % 2 trick to find out if a number is even or odd.
  • When you divide an even number by 2, there are 0 leftovers, so number % 2 will be 0.
  • When you divide an odd number by 2, there is always 1 leftover, so number % 2 will be 1.
  • We use == 0 to ask Python: "Is this number even?"
  • We use == 1 to ask Python: "Is this number odd?"
  • Python will answer your question with a simple True or False on the screen.
Lesson Progress: 0%
Operators
Lesson Incomplete
← Previous: Data Types
Lesson 3 of 16
Next: Variables →