1/36
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
name = value
Variables are defined with
=
refers to assignment.
==
refers to equality
Integers
store whole numbers
Floats
store signed, decimal-point numbers.
Strings
store characters, as text
Booleans
store True or False
None
used to denote a null or empty value.
+, -, *, /
addition, subtraction, multiplication, & division
**
exponentiation
%
modulus
//
for floor division (integer division)
!=
values are not equal
<
value on left is less than value or right
>
value on left is greater than value on right
<=
value on left is less than or equal to value on right
>=
value on left is greater than or equal to value on the right
is
True if both refer to the same object
is not
True if they do not refer to the same object
def( )
you are defining a function
Conditionals
statements that check for a condition, using the if statement, and then only execute a set of code if the condition evaluates as True
else
you can use after an if that will run if the conditional(s) above have not run.
elif
After an if statement, you can have any number of else if to check other conditions
list
a mutable collection of ordered items, that can be of mixed type. Created using square brackets. mutable
start:stop
A sequence of indices (called a slice) can be accessed using
start:stop:step
To skip values in a sequence use
tuple
an immutable collection of ordered items, that can be of mixed type. immutable
dictionary
mutable collection of items, that can be of mixed-type, that are stored as key-value pairs.
in
operator asks whether an element is present inside a collection, and returns a boolean answer.
ord
returns the unicode code point for a one-character string
chr
returns the character encoding of a code point.
Errors
problems with code definition or execution that interrupt running Python code.
ZeroDivisionError
occurs when you try to divide by zero.
NameError
occurs when you try to access a name that Python does not know.
IndexError
occurs when you try to access an index that doesn't exist.
ValueError
occurs when you try to use an illegal value for something.
TypeError
occurs when you try to do something with a variable type that python cannot interpret.