1/52
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Math Operators
Symbols that perform arithmetic operations like addition (+), subtraction (-), multiplication (), division (/), integer division (//), exponentiation (*), and modulus (%).
Integer Division
An operation that divides two numbers and gives only the whole number part of the quotient (no remainder). Example: 7 // 3
Modulus
An operator that gives the remainder after dividing two numbers. Example: 7 % 3
Order of Operations (PEMDAS)
The rules for which operations to perform first: Parentheses, Exponents, Multiplication/Division (left to right), Addition/Subtraction (left to right). Example: (3 + 2) * 5 = 25.
Comparison Operators
Used to compare two values; they return True or False. Examples: == (equal), != (not equal), > (greater than), < (less than), >= (greater than or equal), <= (less than or equal).
Logical Operators
Combine multiple True/False conditions. AND (True if both are true), OR (True if at least one is true), NOT (reverses True/False).
Random() in Python
A function that generates random numbers. random.random() gives a float between 0 and 1; random.randint(a,b) gives an integer between a and b inclusive.
RANDOM(a,b) in AP Pseudocode
Returns a random integer between a and b inclusive.
Python Assignment
Uses = to assign values (x = 5).
AP Pseudocode Assignment
Uses ← to assign values (x ← 5).
Equality in Python
Uses == to check if two values are equal (x == 5).
Equality in AP Pseudocode
Uses = to check equality (x = 5).
Exponentiation in Python
Uses ** (2 ** 3 = 8).
Exponentiation in AP Pseudocode
Uses ^ (2 ^ 3 = 8).
Modulus in Python
Uses % (7 % 3 = 1).
Modulus in AP Pseudocode
Uses MOD (7 MOD 3 = 1).
Logical AND in Python
Written as "and" (True if both sides are True).
Logical AND in AP Pseudocode
Written as AND.
Logical OR in Python
Written as "or" (True if at least one condition is True).
Logical OR in AP Pseudocode
Written as OR.
Logical NOT in Python
Written as "not" (reverses True/False).
Logical NOT in AP Pseudocode
Written as NOT.
Display Output in Python
print().
Display Output in AP Pseudocode
DISPLAY().
Modulus Real-World Use
Checking if a number is even or odd (x % 2 == 0 means even).
Order of Operations Example
3 + 4 * 2 = 11 because multiplication happens before addition.
Comparison Example
5 > 3 is True; 4 == 5 is False.
Logical Example
(x > 2 and x < 10) is True if both conditions are True.
Random Example Python
random.randint(1,6) gives a random integer from 1 to 6.
Random Example AP Pseudocode
RANDOM(1,6) gives a random integer from 1 to 6.
Integer Division Example
14 // 5 = 2 (whole number quotient).
Modulus Example
14 % 5 = 4 (remainder).
PEMDAS Reminder
Parentheses, Exponents, Multiplication/Division, Addition/Subtraction.
Boolean Value
A data type that can only be True or False.
Quotient vs. Remainder
Integer division gives the quotient; modulus gives the remainder.
Practice Check Modulus
9 % 2 = 1 (odd number).
Practice Check Order
(2 + 3) * 4 = 20.
Practice Check Comparison
7 <= 6 = False.
Practice Check Logical
not(False) = True.
Key Python vs. Pseudocode Difference
Python uses == for equality and = for assignment; pseudocode uses = for equality and ← for assignment.
Parentheses Purpose
To control or change the normal order of operations.
Exponent Operator
Raises a number to a power (2 ** 3 = 8).
Random Function Purpose
Creates unpredictability, used in games or simulations.
Python Floor Division Symbol
//.
Python Modulus Symbol
%.
AP Pseudocode Modulus Keyword
MOD.
Random Integer Range Rule
The upper and lower bounds are both included (RANDOM(1,10) can be 1 or 10).
Truth Table AND
True only if both are True.
Truth Table OR
True if one or both are True.
Truth Table NOT
Reverses the condition (NOT True = False).
Practical Example Using All
IF (num MOD 2 = 0 AND num > 5) DISPLAY("Even and greater than 5") ELSE DISPLAY("Other").
Order of Operations Mnemonic
Please Excuse My Dear Aunt Sally.
Quick Difference Integer Division vs. Modulus
Integer division answers “How many times does it fit?” while modulus answers “What’s left over?”.