1/5
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
All the comparison operators
x != y # x is not equal to y
x > y # x is greater than y
x < y # x is less than y
x >= y # x is greater than or equal to y
x <= y # x is less than or equal to y
What are the Logical Operators? What two are Boolean values?
"and", "or", "not" -> All three operators take Boolean operands and produce Boolean values
Boolean values: “True” and “False” with capitalization mattering
Order of precedence
Think of bedmas
Brackets () - Highest
Functions
Exponents [ ** ]
Multiplication/Division/Division Where you round down /Modulo [ * , /, //, % ]
Addition/Subtraction [ +, - ]
Relational/Operators [ ==, !=, >, <, >=, <= ]
Logical “not” [ not ]
Logical “and” [ and ]
logical “or” [ or ] - Lowest
If, else, elif
How to calculate modulo on calculator
Divide the two numbers
Subtract the whatever number to answer to get it to 0.decimal
then multiple by the second number and round
Example:
263 / 14 = 18.785714
We only want 0.785714 so subtract this answer by 18
Multiple that answer by the second number (14) → 14 x .785714 = 10.999996 or 11 rounded
Chained conditionals example
if x < y:
print("x is less than y")
elif x > y:
print("x is greater than y")
else:
print("x and y must be equal")While nested would be:
f x < y:
print("x is less than y")
else:
if x > y:
print("x is greater than y")
else:
print("x and y must be equal")So Chained so no if/else/elif within another if/else/elif. While a nested is the oppositie where there are other
()
f(x) - functions
*, /, //, % -
+, -
><, <=>, =, ==, !=
(Not, and or)
"if"