AP CSP: Operators and Logic Quiz - Dolan

0.0(0)
studied byStudied by 0 people
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/52

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

53 Terms

1
New cards

Math Operators

Symbols that perform arithmetic operations like addition (+), subtraction (-), multiplication (), division (/), integer division (//), exponentiation (*), and modulus (%).

2
New cards

Integer Division

An operation that divides two numbers and gives only the whole number part of the quotient (no remainder). Example: 7 // 3

3
New cards

Modulus

An operator that gives the remainder after dividing two numbers. Example: 7 % 3

4
New cards

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.

5
New cards

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).

6
New cards

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).

7
New cards

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.

8
New cards

RANDOM(a,b) in AP Pseudocode

Returns a random integer between a and b inclusive.

9
New cards

Python Assignment

Uses = to assign values (x = 5).

10
New cards

AP Pseudocode Assignment

Uses ← to assign values (x ← 5).

11
New cards

Equality in Python

Uses == to check if two values are equal (x == 5).

12
New cards

Equality in AP Pseudocode

Uses = to check equality (x = 5).

13
New cards

Exponentiation in Python

Uses ** (2 ** 3 = 8).

14
New cards

Exponentiation in AP Pseudocode

Uses ^ (2 ^ 3 = 8).

15
New cards

Modulus in Python

Uses % (7 % 3 = 1).

16
New cards

Modulus in AP Pseudocode

Uses MOD (7 MOD 3 = 1).

17
New cards

Logical AND in Python

Written as "and" (True if both sides are True).

18
New cards

Logical AND in AP Pseudocode

Written as AND.

19
New cards

Logical OR in Python

Written as "or" (True if at least one condition is True).

20
New cards

Logical OR in AP Pseudocode

Written as OR.

21
New cards

Logical NOT in Python

Written as "not" (reverses True/False).

22
New cards

Logical NOT in AP Pseudocode

Written as NOT.

23
New cards

Display Output in Python

print().

24
New cards

Display Output in AP Pseudocode

DISPLAY().

25
New cards

Modulus Real-World Use

Checking if a number is even or odd (x % 2 == 0 means even).

26
New cards

Order of Operations Example

3 + 4 * 2 = 11 because multiplication happens before addition.

27
New cards

Comparison Example

5 > 3 is True; 4 == 5 is False.

28
New cards

Logical Example

(x > 2 and x < 10) is True if both conditions are True.

29
New cards

Random Example Python

random.randint(1,6) gives a random integer from 1 to 6.

30
New cards

Random Example AP Pseudocode

RANDOM(1,6) gives a random integer from 1 to 6.

31
New cards

Integer Division Example

14 // 5 = 2 (whole number quotient).

32
New cards

Modulus Example

14 % 5 = 4 (remainder).

33
New cards

PEMDAS Reminder

Parentheses, Exponents, Multiplication/Division, Addition/Subtraction.

34
New cards

Boolean Value

A data type that can only be True or False.

35
New cards

Quotient vs. Remainder

Integer division gives the quotient; modulus gives the remainder.

36
New cards

Practice Check Modulus

9 % 2 = 1 (odd number).

37
New cards

Practice Check Order

(2 + 3) * 4 = 20.

38
New cards

Practice Check Comparison

7 <= 6 = False.

39
New cards

Practice Check Logical

not(False) = True.

40
New cards

Key Python vs. Pseudocode Difference

Python uses == for equality and = for assignment; pseudocode uses = for equality and ← for assignment.

41
New cards

Parentheses Purpose

To control or change the normal order of operations.

42
New cards

Exponent Operator

Raises a number to a power (2 ** 3 = 8).

43
New cards

Random Function Purpose

Creates unpredictability, used in games or simulations.

44
New cards

Python Floor Division Symbol

//.

45
New cards

Python Modulus Symbol

%.

46
New cards

AP Pseudocode Modulus Keyword

MOD.

47
New cards

Random Integer Range Rule

The upper and lower bounds are both included (RANDOM(1,10) can be 1 or 10).

48
New cards

Truth Table AND

True only if both are True.

49
New cards

Truth Table OR

True if one or both are True.

50
New cards

Truth Table NOT

Reverses the condition (NOT True = False).

51
New cards

Practical Example Using All

IF (num MOD 2 = 0 AND num > 5) DISPLAY("Even and greater than 5") ELSE DISPLAY("Other").

52
New cards

Order of Operations Mnemonic

Please Excuse My Dear Aunt Sally.

53
New cards

Quick Difference Integer Division vs. Modulus

Integer division answers “How many times does it fit?” while modulus answers “What’s left over?”.