ThatQuiz Test Library Take this test now
Cprog Reviewer Finals (Python)
Contributed by: Fernandez
  • 1. What method is used to append an item to the end of a list?
A) insert()
B) append()
C) extend()
D) add()
  • 2. This Used to simplify resource management, especially for handling external resources like files, network connections, or database connections. It ensures that resources are properly initialized and released, even if an exception occurs during their use.
A) Cleaning up Exception
B) Exception Management
C) Exception handling
D) With statement
  • 3. How can you insert an element at a specific index in a list?
A) insert()
B) extend()
C) append()
D) add()
  • 4. This Removes and returns the element at a specified index.
A) pop()
B) remove()
C) delete()
D) discard()
  • 5. In Python, how can you add a new key-value pair to a dictionary?
A) Using assignment()
B) Using add()
C) Using insert()
D) Using update()
  • 6. This is a concept in programming, including Python, where the evaluation of a logical expression stops as soon as the result can be determined.
A) Short-circuit evaluation
B) Premature termination
C) Direct evaluation
D) Sequential evaluation
  • 7. How can you sort a list of strings in reverse order in Python?
A) sorted_list = sorted(my_list)
B) sorted_list = sort(my_list, reverse=True)
C) sorted_list = sort(my_list)
D) sorted_list = sorted(my_list, reverse=True)
  • 8. This is also known as an anonymous function, This allows you to create a function on-the-fly without having to formally define it using def
A) lambda function
B) def function
C) map function
D) Enumerate function
  • 9. How is a function defined in Python?
A) Using the def keyword
B) Using the define keyword
C) Using the define function
D) Using the function keyword
  • 10. A string that enclosed in triple quotes that provides documentation for a function
A) Arguments
B) Parameters
C) Scope
D) Docstring
  • 11. What is the purpose of the enumerate() function in Python?
A) To iterate over both the elements and their indices in a list
B) To reverse the order of elements in a list
C) To count the total number of elements in a list
D) To remove specific elements from a list
  • 12. How can you remove an element from a set without raising an error if the element does not exist?
A) Using clear()
B) Using pop()
C) Using discard()
D) Using remove()
  • 13. Which method is used to delete a key-value pair associated with a specified key in a dictionary?
A) remove()
B) pop()
C) delete()
D) del()
  • 14. What does the in operator do in Python?
A) Checks if a value is present in a set
B) Checks if a key exists in a dictionary
C) Checks if an element exists in a list
D) Checks if a substring is in a string
  • 15. How can you find the index of the first occurrence of a specific element in a list?
A) Using index()
B) Using search()
C) Using locate()
D) Using find()
  • 16. Which method is used to merge the keys and values from one dictionary into another in Python?
A) combine()
B) merge()
C) append()
D) update()
  • 17. You can use a ______ to iterate over a list by manually managing an index variable.
A) Enumerate
B) While Loop
C) For Loop
D) List Comprehension
  • 18. A loop that is commonly used to iterate over the elements of a list.
A) While Loop
B) For Loop
C) Do While Loop
D) Enumerate
  • 19. What is the output of the following list comprehension? new_list = [x for x in range(10) if x % 2 == 0]
A) [0, 2, 4, 6, 8]
B) [0, 1, 2, 3, 4]
C) [1, 3, 5, 7, 9]
D) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  • 20. This is a built-in function that allows you to apply a specified function to each item in an iterable and returns an iterator of the results.
A) map function
B) list function
C) lambda function
D) Enumerate function
  • 21. How can you create a lambda function that multiplies two numbers?
A) multiply = lambda x, y: x / y
B) multiply = lambda x, y: x + y
C) multiply = lambda x, y: x - y
D) multiply = lambda x, y: x * y
  • 22. This a process of deliberately triggering an error condition within a program to indicate that something unexpected or erroneous has occurred.
A) With statement
B) Raising Exceptions
C) Cleaning up Exception
D) Exception handling
  • 23. What is the output of the following code snippet? my_list = [1, 2, 3, 4] removed_element = my_list.pop(2) print(removed_element)
A) 4
B) 1
C) 2
D) 3
  • 24. This function can be used to create an iterator from elements of an iterable for which a function returns true.
A) index()
B) filter()
C) get()
D) extend()
  • 25. This is a way to extract individual elements from a list and assign them to variables in a single step
A) List unpacking
B) Looping over list
C) sorted list
D) List
  • 26. How can you check if a specific element exists in a collection in Python?
A) Using verify()
B) Using the in operator
C) Using exists()
D) Using check()
  • 27. Which method is used to add elements from another set to a set in Python?
A) update()
B) append()
C) merge()
D) combine()
  • 28. This is a collection of items that are ordered and changeable. It is one of the built-in data types that allows you to store a collection of values
A) List
B) Enumerate
C) For Loop
D) Sorted list
  • 29. How can you define a function that takes two parameters in Python?
A) def my_function(param1; param2)
B) ef my_function(param1 - param2):
C) def my_function(param1 param2):
D) def my_function(param1, param2):
  • 30. What keyword is used to iterate through a collection in Python?
A) iterate
B) loop
C) for
D) while
  • 31. Which keyword is used to specify a function to extract a comparison key from each element for custom sorting in Python?
A) extract
B) sort
C) key
D) compare
  • 32. What keyword is used to reverse the order of elements in a list in Python?
A) sort
B) reverse
C) backward
D) invert
  • 33. How to adds an element to a set
A) Using extend()
B) Using insert()
C) Using add()
D) Using append()
  • 34. A function that allows you to loop over both the elements and their indices in a list.
A) Enumerate
B) While Loop
C) List Comprehension
D) For Loop
  • 35. This is a block of reusable code that performs a specific task or set of tasks
A) Function
B) Arguments
C) Scope
D) Parameters
  • 36. A variables that is defined outside of any function have global scope and can be accessed from anywhere in the program
A) Scope
B) Docstring
C) Parameters
D) Arguments
  • 37. These are the values that the function expects to receive when it is called
A) Parameters
B) Scope
C) Arguments
D) Variables
  • 38. This refers to the values that are passed into a function when it is called.
A) Variables
B) Arguments
C) Parameters
D) Scope
  • 39. These are parameters in a function that have a default value specified in the function definition.
A) Default Arguments
B) Keyword Arguments
C) Positional Arguments
D) Arbitrary Arguments
  • 40. This allow you to pass a variable number of arguments to a function.
A) Keyword Arguments
B) Default Arguments
C) Positional Arguments
D) Arbitrary Arguments
  • 41. These are specified by using the parameter names followed by an equals sign = and the value to be passed.
A) Positional Arguments
B) Arbitrary Arguments
C) Keyword Arguments
D) Default Arguments
  • 42. This is iterating through each element of the list and performing some operation on each element
A) for loop
B) Looping over list
C) sorting list
D) list unpacking
  • 43. This provide a concise way to create a new list by performing an operation on each element of an existing list.
A) Enumerate
B) List Comprehension
C) sorted list
D) List unpacking
  • 44. A method to retrieve the value associated with a specific key.
A) filter()
B) get()
C) index()
D) extend()
  • 45. A function that returns a new sorted list from the elements of the original list. It does not modify the original list.
A) filter()
B) index()
C) sort()
D) sorted()
  • 46. Both sorted() and sort() functions that have a reverse parameter which, when set to True, sorts the list in descending order.
A) Sorting in Reverse Order
B) Custom Sorting
C) Reverse Sorting
D) Sorting Strings
  • 47. Both sorted() and sort() functions that accept a key parameter, which allows you to specify a function to extract a comparison key from each element.
A) Reverse Sorting
B) Custom Sorting
C) Sorting Strings
D) lambda
  • 48. Which escape sequence is used to represent a newline in a string?
A) \'
B) \\
C) \n
D) \"
  • 49. What is the out put of this code first = "Jann Erick" last = "Santos" full = f"{first} {last}" print(full)
A) Erick Santos
B) Jann Erick Santos
C) Jann
D) Jann Santos
  • 50. How would you capitalize the first letter of each word in the string 'course'?
A) print(course.lower())
B) print(course.capitalize())
C) print(course.upper())
D) print(course.title())
  • 51. Which of the following variable names is invalid?
A) _private_var
B) is_published
C) courseName
D) 1st_name
  • 52. Which of the following is an example of a correctly defined integer variable in Python?
A) 1000 = student_count
B) student-count = 1000
C) student_count = 1000
D) student_count = "1000"
  • 53. What is the correct way to define a string variable in Python?
A) course_name = Python Programming'
B) course_name = "Python Programming"
C) course_name = Python Programming
D) course_name = 'Python Programming'
  • 54. How would you print the first character of the string variable 'course'?
A) print(course[-1])
B) print(course[0])
C) print(course[first])
D) print(course[1])
  • 55. Which Python function returns the absolute value of a number?
A) roundl()
B) abs()
C) ciel()
D) value()
  • 56. Which function from the math module returns the smallest integer greater than or equal to a given number?
A) math.floor()
B) math.sqrt()
C) math.ceil()
D) math.pow()
  • 57. What is the result of the following code? x = "10" y = int(x) + 1 print(y)
A) 1
B) 101
C) 10
D) 11
  • 58. They cannot be a reserved keyword.They should be meaningful and descriptive names.They cannot start with a number like. They cannot contain space or hyphen
A) String
B) variable names
C) Arguments
D) function
  • 59. These are passed to a function in a specific order, and their values are assigned to the corresponding parameters defined in the function's signature
A) Positional Arguments
B) Default Arguments
C) Keyword Arguments
D) Arbitrary Arguments
  • 60. Bonus ( ˘ ³˘)♥︎
A) Papasa ako
B) Di ako Papasa
  • 61. In Python this refers to the process of managing errors that occur during the execution of a program
A) Exception Management
B) Handling Exception
C) Exception handling
D) Cleaning up Exception
  • 62. A function is defined using the def keyword, followed by the function name, a pair of parentheses (), and a colon :
A) Function Reusability
B) Function Body
C) Function Call
D) Function Definition
  • 63. This is a block of code that is indented beneath the def statement. It contains the instructions that the function will execute when called
A) Function Definition
B) Function Body
C) Function Reusability
D) Function Call
  • 64. This execute a function, you use its name followed by a pair of parentheses, optionally containing the arguments (values) that you want to pass to the function
A) Function Body
B) Function Definition
C) Function Call
D) Function Reusability
  • 65. This functions can be called multiple times from different parts of your program, allowing you to reuse the same code logic
A) Function Reusability
B) Function Body
C) Function Call
D) Function Definition
  • 66. This method sorts the list in-place, meaning it modifies the original list
A) index()
B) filter()
C) sort()
D) sorted()
  • 67. This is used to compare two values. It allows you to determine the relationship between these values
A) If Statement
B) Comparison Operator
C) If-else Statement
D) Conditional Statement
  • 68. This allow you to control the flow of execution in a program based on certain conditions.
A) If-else Statement
B) Conditional Statement
C) elif Statement
D) If Statement
  • 69. This statement is used to execute a block of code only if a specified condition is true. If the condition is false, the code block is skipped.
A) Nested if Statements
B) If Statement
C) If-else Statement
D) elif Statement
  • 70. This statement provides an alternative code block to execute if the condition is false.
A) If-else Statement
B) If Statement
C) elif Statement
D) Nested if Statements
  • 71. This statement allows you to check multiple conditions in a sequence. It is used when you have more than two possible outcomes.
A) elif Statement
B) Nested if Statements
C) If Statement
D) If-else Statement
  • 72. This statement allows you to place an if statement inside another if statement to handle more complex conditions.
A) If Statement
B) If-else Statement
C) Nested if Statements
D) elif Statement
  • 73. This allows you to write a concise one-line if-else statement.
A) Ternary Operator
B) Conditional Statement
C) Logical Operator
D) Comparison Operator
  • 74. These are used to perform operations on Boolean values (True or False).
A) Comparison Operator
B) Ternary Operator
C) Logical Operator
D) Conditional Statement
  • 75. This operator returns True if both of the operands are True. Otherwise, it returns False.
A) or
B) and
C) not
D) equals
  • 76. This operator returns True if at least one of the operands is True. If both operands are False, it returns False.
A) equals
B) and
C) or
D) not
  • 77. This operator is a unary operator that negates the value of a Boolean expression. It returns True if the expression is False, and False if the expression is True.
A) and
B) equals
C) or
D) not
  • 78. This can optionally return a value using the return statement.
A) Function Reusability
B) Return Value
C) Function Definition
D) Function Call
  • 79. What this sign "==" means?
A) Not equal to
B) Less than or equal to
C) Greater than or equal to
D) Equal to
  • 80. What this sign "!=" means?
A) Equal to
B) Greater than or equal to
C) Not equal to
D) Less than or equal to
Students who took this test also took :

Created with That Quiz — a math test site for students of all grade levels.