AP Computer Science Principles: Midterms - Dolan

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

1/144

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

145 Terms

1
New cards

Output (Python)

print()

2
New cards

Output (AP Pseudocode)

DISPLAY

3
New cards

What does output mean in programming?

Showing information to the user (on the screen)

4
New cards

What data type is 5?

int (integer)

5
New cards

What data type is 3.14?

float

6
New cards

What data type is "Hello"?

str (string)

7
New cards

What data type is True?

bool (Boolean)

8
New cards

Boolean values in AP pseudocode

TRUE and FALSE

9
New cards

What is a variable?

A named container that stores a value that can change

10
New cards

Python variable assignment symbol

=

11
New cards

AP pseudocode assignment symbol

12
New cards

Python is case sensitive means

Age and age are different variables

13
New cards

Rules for variable names

Start with letter/_ ; use letters/numbers/_ ; no keywords ; meaningful names

14
New cards

What is a string?

Text (characters) inside quotes

15
New cards

What is string concatenation?

Joining strings together using +

16
New cards

How do you concatenate strings in Python?

Use +

17
New cards

How do you add a space when concatenating?

Put " " between words in the concatenation

18
New cards

Why can’t you add a number to a string with + in Python?

Different data types; must convert number to a string

19
New cards

Convert a number to a string in Python

str(number)

20
New cards

What does input() return by default in Python?

A string

21
New cards

How do you get user input in Python?

variable = input("prompt")

22
New cards

How do you get user input in AP pseudocode?

variable ← INPUT("prompt")

23
New cards

How do you convert input to an integer in Python?

int(input("prompt"))

24
New cards

What is a comment?

A note for humans that the computer ignores

25
New cards

Python comment symbol

#

26
New cards

Purpose of comments

Explain code and make it easier to understand/debug

27
New cards

What is debugging?

Finding and fixing errors in code

28
New cards

Syntax error

Code is written incorrectly; program won’t run

29
New cards

Runtime error

Program runs until it crashes while executing

30
New cards

Logic error

Program runs but gives the wrong output

31
New cards

Overflow error

Too-large number for the allowed storage/type (too much info)

32
New cards

Roundoff error

Small inaccuracies caused by rounding decimals

33
New cards

Common debugging strategy: tracing

Step through code line by line and track variable values

34
New cards

Common debugging strategy: test cases

Try different inputs to check behavior

35
New cards

Arithmetic operators

+, -, *, / (and others like %, **)

36
New cards

Addition operator

+

37
New cards

Subtraction operator

-

38
New cards

Multiplication operator

*

39
New cards

Division operator

/

40
New cards

Python division returns

A float (decimal), even if dividing integers

41
New cards

Exponent operator in Python

**

42
New cards

Exponent operator in AP pseudocode

^

43
New cards

What is modulus?

Remainder after division

44
New cards

Modulus operator in Python

%

45
New cards

Modulus operator in AP pseudocode

MOD

46
New cards

What is 10 % 2?

0

47
New cards

What is 7 % 3?

1

48
New cards

If the first number is smaller in modulus (3 % 5)

The answer is 3

49
New cards

How to check if a number is even

number % 2 == 0

50
New cards

How to check if a number is odd

number % 2 == 1

51
New cards

Order of operations acronym

PEMDAS

52
New cards

PEMDAS order

Parentheses, Exponents, Multiply/Divide/Modulus, Add/Subtract

53
New cards

What is 5 + 3 * 2?

11

54
New cards

What is (5 + 3) * 2?

16

55
New cards

Comparison operators produce

Boolean values (True/False)

56
New cards

Equality operator in Python

==

57
New cards

Equality operator in AP pseudocode

=

58
New cards

Not equal operator in Python

!=

59
New cards

Not equal operator in AP pseudocode

≠ or !=

60
New cards

Greater than operator

>

61
New cards

Less than operator

<
62
New cards

Greater than or equal operator

=

63
New cards

Less than or equal operator

64
New cards

Logical operators combine

Boolean expressions

65
New cards

AND means

True only if both conditions are true

66
New cards

OR means

True if at least one condition is true

67
New cards

NOT means

Flips the truth value (True becomes False, False becomes True)

68
New cards

Why parentheses matter in logic

They change the order and meaning of the condition

69
New cards

Using RANDOM(a, b) in AP pseudocode

Returns a random integer from a to b inclusive

70
New cards

Python equivalent of RANDOM(a, b)

random.randint(a, b)

71
New cards

What is an algorithm?

A step-by-step set of instructions to solve a problem

72
New cards

What is a control structure?

A structure that controls the flow of a program

73
New cards

Sequence

Running statements in order from top to bottom

74
New cards

Selection

Choosing between paths using IF/ELSE

75
New cards

Iteration

Repeating steps using loops

76
New cards

IF statement purpose

Runs code only when a condition is true

77
New cards

ELSE purpose

Runs code when the IF condition is false

78
New cards

FOR loop purpose

Repeats a set number of times

79
New cards

WHILE loop purpose

Repeats while a condition stays true

80
New cards

Infinite loop

A loop that never stops because the condition never becomes false

81
New cards

Nesting

Putting a loop inside an if, or an if inside a loop, etc.

82
New cards

Most common nesting pattern

Loop through items and use IF to check each one

83
New cards

What is a list?

An ordered collection of items stored in one variable

84
New cards

Python list indexing starts at

0

85
New cards

AP pseudocode list indexing starts at

1

86
New cards

How to create a list in Python

name = [items]

87
New cards

How to create a list in AP pseudocode

name ← [items]

88
New cards

How to get list length in Python

len(list)

89
New cards

How to get list length in AP pseudocode

length(list)

90
New cards

Last index in Python

len(list) - 1

91
New cards

Last index in AP pseudocode

length(list)

92
New cards

Traversing a list means

Going through each item in the list

93
New cards

Python for-each traversal

for item in list:

94
New cards

AP pseudocode for-each traversal

FOR EACH item IN list

95
New cards

Searching a list common pattern

Use a found flag (found = False/TRUE)

96
New cards

Found flag purpose

Tracks whether the target value was found in the list

97
New cards

Add to end of list in Python

list.append(value)

98
New cards

Add to end of list in AP pseudocode

APPEND(list, value)

99
New cards

Insert into a list in Python

list.insert(index, value)

100
New cards

Insert into a list in AP pseudocode

INSERT(list, position, value)