Python Operators
Server Academy Members Only
Sorry, this lesson is only available to Server Academy members. Create a free account now to get instant access to this and more free courses. Click the Sign Up Free button below to get access to our free courses now, or sign in if you have an account.
Python operators are used to complete operations with numbers like arithmetic, assignment, comparisons, logical and more.
Here is a table that will explain the python operators:
Operator | Description | Example |
+ | Add | 1 + 1 = 2 |
- | Subtract | 2 - 1 = 1 |
* | Multiply | 2 * 2 = 4 |
/ | Divide | 10 / 4 = 2.5 |
// | Floor division | 10 // 4 = 2 |
% | Modulo | 10 % 4 = 2 |
** | Exponent | 2 ** 4 = 16 |
Feel free to try these examples in the python terminal above! Addition, subtraction, multiplication and division make sense to most people, so let's focus on the more confusing operators here that you might not be familiar with.
Floor Division
Floor division in the simplest of terms divides two numbers then rounds that number down. Since 10 / 4 = 2.5, it will round 2.5 down to 2 like so:
10 // 4
Modulo
The modulus operator will return the remainder of a division. Let's take for example, 10 / 4.
4 * 2 = 8, and the remainder is 2:
10 % 4
To understand this one better I would encourage you to use the Python console above to experiment with the modulo more.
Exponent
This one is pretty simple. 5 ** 5 is read as 5^5, or 5 to the 5th power. So 5*5*5*5*5 = 3125
5**5
Server Academy Members Only
Want to access this lesson? Just sign up for a free Server Academy account and you'll be on your way. Already have an account? Click the Sign Up Free button to get started..
Saving Progress...
Python 3 Fundamentals
Installing Python on Windows • 1hr 17min
0 / 4 lessons complete
Section Overview
Free Preview Lesson
Text | 1 min
Downloading and Installing Python on Windows
Free Preview Lesson
Text | 8 min
Installing and configuring VS Code for Python
Free Preview Lesson
Text | 8 min
Lab: Installing Python
Free Preview Lesson
Devops Lab | 60
Python Basics • 28min
0 / 7 lessons complete
Python Variables • 41min
0 / 8 lessons complete
Section Overview
Free Preview Lesson
Text | 4 min
Casting
Free Preview Lesson
Text | 4 min
Strings
Free Preview Lesson
Text | 5 min
Booleans
Free Preview Lesson
Text | 8 min
User Input
Free Preview Lesson
Text | 2 min
Numbers
Free Preview Lesson
Text | 7 min
NoneType
Free Preview Lesson
Text | 5 min
Assignment: Write a Mad Libs Script
Free Preview Lesson
Text | 6 min
Even more Python Variables! • 41min
0 / 6 lessons complete
Python Lists
Free Preview Lesson
Text | 8 min
Python Tuples
Free Preview Lesson
Text | 7 min
Python Sets
Free Preview Lesson
Text | 7 min
Frozensets
Free Preview Lesson
Text | 6 min
Dictionaries
Free Preview Lesson
Text | 8 min
Iterator and Iterable
Free Preview Lesson
Text | 5 min
Conditional Statements • 15min
0 / 3 lessons complete
Section Overview
Free Preview Lesson
Text | 2 min
If Statements
Free Preview Lesson
Text | 6 min
Try, Except
Free Preview Lesson
Text | 7 min
Writing Functions • 30min
0 / 5 lessons complete
Section Overview
Free Preview Lesson
Text | 3 min
Defining Functions
Free Preview Lesson
Text | 4 min
Importing functions from another file
Free Preview Lesson
Text | 4 min
Assignment: Rock, paper, scissors
Free Preview Lesson
Text | 12 min
Assignment: Count Dictionary Words
Free Preview Lesson
Text | 7 min
Python Loops • 23min
0 / 5 lessons complete
Section Overview
Free Preview Lesson
Text | 2 min
For In Loops
Free Preview Lesson
Text | 5 min
While Loops
Free Preview Lesson
Text | 5 min
Nested Loops
Free Preview Lesson
Text | 3 min
Python Loops Challenge!
Free Preview Lesson
Text | 8 min
Python PIP and Modules • 18min
0 / 4 lessons complete
Section Overview
Free Preview Lesson
Text | 3 min
Installing Python PIP
Free Preview Lesson
Text | 4 min
Installing Modules with PIP
Free Preview Lesson
Text | 5 min
Importing Modules
Free Preview Lesson
Text | 6 min
RegEx • 26min
0 / 4 lessons complete
Section Overview
Free Preview Lesson
Text | 4 min
Regex 101
Free Preview Lesson
Text | 10 min
Importing Regex and manipulating strings
Free Preview Lesson
Text | 7 min
Regex Challenge!
Free Preview Lesson
Text | 5 min
Working with APIs • 12min
0 / 3 lessons complete
Making HTTP Requests
Free Preview Lesson
Text | 3 min
Working with JSON
Free Preview Lesson
Text | 5 min
Get your weather with the OpenWeatherMap
Free Preview Lesson
Text | 4 min
Course Conclusion • 2min
0 / 1 lessons complete
Easy to follow