Python Operators

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:

OperatorDescriptionExample
+Add1 + 1 = 2
-Subtract2 - 1 = 1
*Multiply 2 * 2 = 4
/Divide10 / 4 = 2.5
//Floor division10 // 4 = 2
%Modulo10 % 4 = 2
**Exponent2 ** 4 = 16
Python Operators Table

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..

0 0 votes
Lesson Rating
Subscribe
Notify of
profile avatar
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

profile avatar
felixt(@felixt)
6 months ago

Easy to follow

Saving Progress...

Sign up for free!

Sign up for free and get instant access to this course!.

Python 3 Fundamentals

0%

0/1 Lessons

Installing Python on Windows

• 1hr 17min

0 / 4 lessons complete

Python Basics

• 28min

0 / 7 lessons complete

Python Variables

• 41min

0 / 8 lessons complete

Even more Python Variables!

• 41min

0 / 6 lessons complete

Conditional Statements

• 15min

0 / 3 lessons complete

Writing Functions

• 30min

0 / 5 lessons complete

Python Loops

• 23min

0 / 5 lessons complete

Python PIP and Modules

• 18min

0 / 4 lessons complete

RegEx

• 26min

0 / 4 lessons complete

Working with APIs

• 12min

0 / 3 lessons complete

Course Conclusion

• 2min

0 / 1 lessons complete