String
Integer
Float (number with decimal point)
Boolean value (either True or False)
Complex number
Ordered, mutable sequence of (possibly duplicate) values
Ordered, immutable sequence of (possily duplicate) values
Unordered, immutable sequence of unique values
Ordered, mutable sequence of unique data where each datum is mapped to a value
Addition
Unary positive, makes number positive
Subtraction
Unary negative, makes number negative
Multiplication
Division
Floor division (rounds division down)
Modulo (remainder of division)
Exponentiation
Assignment operator
Assigns the value stored in the variable plus the value
Assigns the value stored in the variable minus the value
Assigns the value stored in the variable times the value
Assigns the value stored in the variable divided by the value
a/=b is a=a//b
a%=b is a=a%b
a&=b is a=a&b
a|=b is a=a|b
a^=b is a=a^b
a>>>=b is a=a>>>b
a><<=b is a=a><<b
Is equal to
Is not equal to
Greater than
Less than
Greater than or equal to
Less than or equal to
Bitwise AND
Bitwise OR
Bitwise XOR
Arithmetic shift left (shifts all the bits one space to the left, essentially multiplying it by 2)
Logical shift right (shifts all the bits one space to the right, essentially dividing it by 2)
Bitwise NOT
AND operator
OR operator
NOT operator
Checks if two objects are the exact same object, not just the same value
Checks if two objects aren't the exact same object, even if they have the same value
Checks if an object is an element of another
Checks if an object isn't an element of another
Applies method to object
list.sort()
Denotes class of an object
Denotes instance of an object
Used to separate parameters
Instantiates data values of a list
Reference operator for a sequence container
Denotes generics of a function
Defines a tuple
Denotes parameters of a function
Denotes a class' superclass
Declares a function
Instantiates a dictionary
Instantiates a class object
Return annotation for functions, although doesn't force that return type
Defines a block
Defines a lambda expression
Declares a string
Declares a triple quote string, that can span multiple lines and treats special characters as normal
"""This is a triple quote string!"""
Declares a string
The splat; indicates unknown amount of arguments for a parameter and treats them as one tuple
Concatenates strings
'These are '+'two strings!'
List indexing operator, where start represents first index to return, stop represents the last index to return, and step means that only nth index in the new list will be kept
list[3:6]
list[::2]
list[3:6:2]
Decorator operator; denotes a method decorator (a function wrapped around another function)
Used for declaring functions
def function(args):
function code
Switches logic flow based on an output
match object:
case 1:
code executed if object == 1
case 2:
code executed if object == 2
Used for declaring case statement in a match statement
Default case in a switch statement
Executes code if condition is true
if condition:
code
Loops code while a condition is true
while condition:
code
Used for declaring a coroutine expression that can be asynchronously run
Executes code for every object in another object
Attempts to execute code and jumps to the subsequent except on an error
try:
code
Executes code on failed try statement
except:
code
Executes code after try and except blocks
Executes code on true condition if the last if statement was false
if condition:
code
elif condition:
code
Executes code when if or elif isn't executed
Used for testing if two variables are the same
Represents logical AND operator
Represents logical OR operator
Represents logical NOT operator
Used for referencing objects in an array or string
Creates an alias name for an object
Imports classes and modules
Terminates a function, returning a value
Passes by an empyt block
if 1 == 1: pass
Continues to the next iteration of a loop
Breaks from a loop
Used to import specific methods from class
Executes code with resource strictly within the block
with open("media",
"option") as object:
code
Used to handle class or variable with an alias name
Raises an error object
Default case in a match statement
Used to declare public variable in a method
Deletes an object from memory
Represents a true boolean value
True
Represents a false boolean value
False
Represents a null value
None
Declares a lambda expression
References the class instance
Declares a class
class class(parent):
class code
Declares a class
class class(parent):
class code
Constructor of a class (method to make objects of a class)
Returns the iterator object of a class
Returns the iterator object of a class
String
Integer
Float
Float with 1 decimal place, the 1 can be modified to imply more decimal places
Integer in hexadecimal (lowercase a b c d e f)
Integer in hexadecimal (uppercase A B C D E F)
Bell or alert, has hex code 0x07
Backspace, has hex code 0x08
Control-X
Control-X
Escape, has hex code 0x1b
Newline, has hex code 0x0a
Space, has hex code 0x20
Space, has hex code 0x20
Vertical tab, has hex code 0x0b
Used to tell compiler the rest of this line is not to be compiled
#This isn't executed