💻
Python Zero to Hero
  • Python Zero to Hero
  • What is Python?
    • What is Python?
      • High Level
      • Intrepreted
      • General Purpose
    • Tooling
    • Hello, World!
    • Variables
    • Operators
    • Object Orientated Programming
    • Boolean Values
    • If Statements
    • Loops
    • Functions
      • Scope
    • Python Libraries
    • Virtual Environments
      • PyEnv
  • Advanced
    • Introduction
    • Set Theory
Powered by GitBook
On this page

Was this helpful?

  1. What is Python?

Operators

Let's talk about operators. An operator is something between 2 variables / values and does something to them.

For example, the addition operator:

x = 3 + 1
# x = 4

Python supports many maths operators:

3 + 1
3 / 1 # divided by
3 * 4 # times
2 ** 2 # 2 to the power of 4
2 % 3 # 2 mod 3

Now the cool thing, operators don't just work on numbers. They work on strings too. And lists. And dictionaries.

[3, 2] + [6, 7]
# [3, 2, 6, 7]
"Hello, " + "World!"
# "Hello, World!"

Well, operators work on any data structure that has implemented a magic method for them.

Magic methods are rather wild, but require prequesite knolwedge of object orientated programming fiest.

PreviousVariablesNextObject Orientated Programming

Last updated 4 years ago

Was this helpful?