COMP110 Final MC Practice

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/244

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:53 PM on 4/29/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

245 Terms

1
New cards

What is a bool data type in Python?

A data type for storing True/False values.

2
New cards

What is an int data type in Python?

A data type for storing whole numbers, such as -10, 3, or 100.

3
New cards

What is a str data type in Python?

A data type for storing text.

4
New cards

What is a float data type in Python?

A data type for storing numbers with decimals, such as 1.0, 3.14, or -0.1.

5
New cards

Can an int literal begin with any number of zeroes in Python?

No

6
New cards

Which function determines the type of an object in Python?

type()

7
New cards

What does len() do in Python?

Returns the length of a sequence, such as a string or list.

8
New cards

What does int() do to a float?

It removes/truncates the decimal part.

9
New cards

What does str() do?

Converts a value into a string.

10
New cards

What does the % operator do?

Returns the remainder after division.

11
New cards

What does 102 % 5 evaluate to?

2.

12
New cards

What does "110" + "110" evaluate to?

"110110"

13
New cards

What does "hehe" * 2 evaluate to?

"hehehehe".

14
New cards

What does "map"[1] evaluate to?

"a"

15
New cards

What index does Python start with?

0.

16
New cards

What does "12345"[len("12345") - 1] evaluate to?

"5".

17
New cards

What does str(3.0 + 3.0) evaluate to?

"6.0".

18
New cards

What does 4 % 2 evaluate to?

0.

19
New cards

What does int("5" + "4") + 54 evaluate to?

108.

20
New cards

What does int(3.8 + 1) evaluate to?

4.

21
New cards

What type does 1.5 + 2 evaluate to?

float.

22
New cards

What value does 1.5 + 2 evaluate to?

3.5.

23
New cards

What type does len("cottage") evaluate to?

int.

24
New cards

What value does len("cottage") evaluate to?

7.

25
New cards

What type does "True" evaluate to?

str, because the quotes make it a string.

26
New cards

What type does len("Pet") > 2 evaluate to?

bool.

27
New cards

What value does len("Pet") > 2 evaluate to?

True.

28
New cards

What type does 2.0 + 2 ** 2 evaluate to?

float.

29
New cards

What value does 2.0 + 2 ** 2 evaluate to?

6.0.

30
New cards

What does str(110) * 2.1 evaluate to?

TypeError, because strings can be multiplied by ints, not floats.

31
New cards

What does float("100.0") / 20 evaluate to?

5.0.

32
New cards

What does 21 // 2 ** 2 + 3 evaluate to?

8.

33
New cards

What does float("220") >= float("100" + "100") evaluate to?

False.

34
New cards

What does int("COMP 110"[5]) + 99.0 evaluate to?

100.0.

35
New cards

What does (42 % 4) == (79 % 11) evaluate to?

True.

36
New cards

What does int(4.99) evaluate to?

4.

37
New cards

Which operator concatenates two strings?

+.

38
New cards

What is a function definition?

Code that creates/specifies a function, including the signature and indented body.

39
New cards

What is a function call?

Code that invokes/executes a function by writing the function name followed by parentheses.

40
New cards

Is defining a function the same as calling it?

No

41
New cards

Does defining a function run the function body?

No. The body runs only when the function is called.

42
New cards

Are function calls expressions that evaluate to a specific data type?

Yes

43
New cards

When a function is called, where is its frame added?

The stack.

44
New cards

In a memory diagram, where are function names stored?

The stack.

45
New cards

What is output in a memory diagram?

The area where printed values appear.

46
New cards

What is a function signature?

The first line of a function definition with def, function name, parameters, parameter types, and return type.

47
New cards

Why is a function signature important?

It tells users what inputs the function needs and what type of value it returns.

48
New cards

What is a parameter?

A variable listed in the function signature that represents an expected input.

49
New cards

What is an argument?

The actual value passed into a function when it is called.

50
New cards

Are arguments used in function calls?

Yes

51
New cards

What is a return type?

The type annotation after the arrow -> in a function signature.

52
New cards

What does return do?

Ends the function and sends a value back to where the function was called.

53
New cards

What does print() do?

Displays a value in output but does not return that value.

54
New cards

Are print() and return identical?

No

55
New cards

What happens if a function has no return statement?

It returns None by default.

56
New cards

What does the return address, or RA, specify?

The line of code where execution returns after the function finishes.

57
New cards

Given def pet(w: str, x: str) -> int:, what is the function name?

pet.

58
New cards

Given def pet(w: str, x: str) -> int:, what are the parameters?

w and x.

59
New cards

Given def pet(w: str, x: str) -> int:, what are the parameter types?

Both are str.

60
New cards

Given def pet(w: str, x: str) -> int:, what is the return type?

int.

61
New cards

Given def pet(w: str, x: str) -> int:

return len(w) + len(x)

what does pet("Louie", "Sami") return?

9.

62
New cards

What is the signature for a function total that takes two floats num1 and num2 and returns a float?

def total(num1: float, num2: float) -> float:

63
New cards

What is the signature for a function get_char that takes a str word and int index and returns a str?

def get_char(word: str, index: int) -> str:

64
New cards

What is the result of the following function call? evaluate_length("airplane")

8.

65
New cards

What is the signature for pos_or_neg taking int number and returning str?

def pos_or_neg(number: int) -> str:

66
New cards

What is the signature for gcd taking two ints num_one and num_two and returning int?

def gcd(num_one: int, num_two: int) -> int:

67
New cards

What is control flow?

The order in which statements are evaluated or executed.

68
New cards

What is the standard mode of control flow?

Linear (top to bottom)

69
New cards

What does a conditional statement allow?

It lets a program choose which code block to run based on a condition.

70
New cards

Does every if statement need an else?

No

71
New cards

What type should an if condition evaluate to?

bool.

72
New cards

What must an if condition evaluate to in order to enter the then block?

True.

73
New cards

What must an if condition evaluate to in order to enter the else block?

False.

74
New cards

In an if/elif/else structure, can multiple branches run in the same pass?

No. Only one matching branch runs

75
New cards

Can you name a variable else in Python?

No. else is a reserved keyword.

76
New cards

What happens when return is encountered inside an if block?

The function immediately exits and returns that value.

77
New cards

What is the order of boolean operations for not, and, or?

not first, then and, then or.

78
New cards

What does and require to be True?

Both sides must be True.

79
New cards

What does or require to be True?

At least one side must be True.

80
New cards

What does not do?

Flips True to False or False to True.

81
New cards

What does (not False or True) and False evaluate to?

False.

82
New cards

What does (True and False) == (True and True) evaluate to?

False.

83
New cards

What does not (False or False) and (8 == 8) evaluate to?

True.

84
New cards

What does (False and False) or (10 <= 8) evaluate to?

False.

85
New cards

What does (not False) and True == True evaluate to?

True.

86
New cards

What does (not False) or (True and False) evaluate to?

True.

87
New cards

What does True and (7 < 3 * 4 / 6) evaluate to?

False.

88
New cards

What does (not False) != True evaluate to?

False.

89
New cards

What does not (True and False) and (False or not False) evaluate to?

True.

90
New cards

What does "XYZ" == "XYZ" or "B" == "C" evaluate to?

True.

91
New cards

What does 5 ** 2 >= 5 * 5 and 110 % 10 == 0 evaluate to?

True.

92
New cards

What is recursion?

A function calling itself.

93
New cards

What is the base case in recursion?

The case that stops recursion and does not call the function again.

94
New cards

What is the recursive case in recursion?

The case where the function calls itself with a changed argument.

95
New cards

What is the purpose of the recursive case?

To progress toward the base case.

96
New cards

What happens if a recursive function has no base case?

It enters infinite recursion until Python raises RecursionError.

97
New cards

What error can occur from recursion with no base case?

RecursionError.

98
New cards

What must a recursive function have to avoid infinite recursion?

A base case, a recursive case that progresses toward it, and changing arguments.

99
New cards

Does simply calling itself guarantee recursion will stop?

No. It must progress toward a reachable base case.

100
New cards

What is a local variable?

A variable declared inside a function that only exists in that function’s frame.