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) extend()
C) add()
D) append()
  • 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 handling
C) With statement
D) Exception Management
  • 3. How can you insert an element at a specific index in a list?
A) extend()
B) insert()
C) append()
D) add()
  • 4. This Removes and returns the element at a specified index.
A) pop()
B) delete()
C) remove()
D) discard()
  • 5. In Python, how can you add a new key-value pair to a dictionary?
A) Using insert()
B) Using add()
C) Using update()
D) Using assignment()
  • 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) Direct evaluation
B) Premature termination
C) Short-circuit evaluation
D) Sequential evaluation
  • 7. How can you sort a list of strings in reverse order in Python?
A) sorted_list = sort(my_list, reverse=True)
B) sorted_list = sorted(my_list, reverse=True)
C) sorted_list = sort(my_list)
D) sorted_list = sorted(my_list)
  • 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) map function
B) lambda function
C) def function
D) Enumerate function
  • 9. How is a function defined in Python?
A) Using the define function
B) Using the function keyword
C) Using the def keyword
D) Using the define keyword
  • 10. A string that enclosed in triple quotes that provides documentation for a function
A) Arguments
B) Docstring
C) Scope
D) Parameters
  • 11. What is the purpose of the enumerate() function in Python?
A) To reverse the order of elements in a list
B) To remove specific elements from a list
C) To iterate over both the elements and their indices in a list
D) To count the total number of elements in 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 discard()
C) Using remove()
D) Using pop()
  • 13. Which method is used to delete a key-value pair associated with a specified key in a dictionary?
A) pop()
B) delete()
C) del()
D) remove()
  • 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 find()
B) Using index()
C) Using locate()
D) Using search()
  • 16. Which method is used to merge the keys and values from one dictionary into another in Python?
A) append()
B) merge()
C) update()
D) combine()
  • 17. You can use a ______ to iterate over a list by manually managing an index variable.
A) List Comprehension
B) Enumerate
C) For Loop
D) While Loop
  • 18. A loop that is commonly used to iterate over the elements of a list.
A) While Loop
B) For Loop
C) Enumerate
D) Do While Loop
  • 19. What is the output of the following list comprehension? new_list = [x for x in range(10) if x % 2 == 0]
A) [0, 1, 2, 3, 4]
B) [0, 2, 4, 6, 8]
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) Enumerate function
C) lambda function
D) list 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) Exception handling
B) Cleaning up Exception
C) Raising Exceptions
D) With statement
  • 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) 2
B) 3
C) 4
D) 1
  • 24. This function can be used to create an iterator from elements of an iterable for which a function returns true.
A) filter()
B) index()
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) Looping over list
B) List unpacking
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 check()
D) Using exists()
  • 27. Which method is used to add elements from another set to a set in Python?
A) merge()
B) update()
C) combine()
D) append()
  • 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) Enumerate
B) For Loop
C) Sorted list
D) List
  • 29. How can you define a function that takes two parameters in Python?
A) def my_function(param1 param2):
B) def my_function(param1; param2)
C) ef my_function(param1 - param2):
D) def my_function(param1, param2):
  • 30. What keyword is used to iterate through a collection in Python?
A) for
B) loop
C) while
D) iterate
  • 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) key
C) sort
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 add()
B) Using insert()
C) Using extend()
D) Using append()
  • 34. A function that allows you to loop over both the elements and their indices in a list.
A) While Loop
B) Enumerate
C) For Loop
D) List Comprehension
  • 35. This is a block of reusable code that performs a specific task or set of tasks
A) Parameters
B) Scope
C) Function
D) Arguments
  • 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) Arguments
C) Docstring
D) Parameters
  • 37. These are the values that the function expects to receive when it is called
A) Scope
B) Arguments
C) Parameters
D) Variables
  • 38. This refers to the values that are passed into a function when it is called.
A) Arguments
B) Scope
C) Parameters
D) Variables
  • 39. These are parameters in a function that have a default value specified in the function definition.
A) Keyword Arguments
B) Arbitrary Arguments
C) Positional Arguments
D) Default Arguments
  • 40. This allow you to pass a variable number of arguments to a function.
A) Positional Arguments
B) Arbitrary Arguments
C) Keyword Arguments
D) Default Arguments
  • 41. These are specified by using the parameter names followed by an equals sign = and the value to be passed.
A) Arbitrary Arguments
B) Keyword Arguments
C) Default Arguments
D) Positional Arguments
  • 42. This is iterating through each element of the list and performing some operation on each element
A) list unpacking
B) for loop
C) Looping over list
D) sorting list
  • 43. This provide a concise way to create a new list by performing an operation on each element of an existing list.
A) List unpacking
B) sorted list
C) List Comprehension
D) Enumerate
  • 44. A method to retrieve the value associated with a specific key.
A) index()
B) get()
C) filter()
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) sorted()
B) filter()
C) index()
D) sort()
  • 46. Both sorted() and sort() functions that have a reverse parameter which, when set to True, sorts the list in descending order.
A) Sorting Strings
B) Reverse Sorting
C) Custom Sorting
D) Sorting in Reverse Order
  • 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) Custom Sorting
B) lambda
C) Sorting Strings
D) Reverse Sorting
  • 48. Which escape sequence is used to represent a newline in a string?
A) \\
B) \"
C) \'
D) \n
  • 49. What is the out put of this code first = "Jann Erick" last = "Santos" full = f"{first} {last}" print(full)
A) Jann Erick Santos
B) Erick Santos
C) Jann Santos
D) Jann
  • 50. How would you capitalize the first letter of each word in the string 'course'?
A) print(course.lower())
B) print(course.upper())
C) print(course.title())
D) print(course.capitalize())
  • 51. Which of the following variable names is invalid?
A) is_published
B) _private_var
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[1])
C) print(course[first])
D) print(course[0])
  • 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.ceil()
B) math.floor()
C) math.sqrt()
D) math.pow()
  • 57. What is the result of the following code? x = "10" y = int(x) + 1 print(y)
A) 101
B) 11
C) 10
D) 1
  • 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) Arguments
B) function
C) variable names
D) String
  • 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) Keyword Arguments
C) Default 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) Cleaning up Exception
C) Handling Exception
D) Exception handling
  • 62. A function is defined using the def keyword, followed by the function name, a pair of parentheses (), and a colon :
A) Function Call
B) Function Definition
C) Function Reusability
D) Function Body
  • 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 Call
C) Function Reusability
D) Function Body
  • 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 Call
B) Function Reusability
C) Function Definition
D) Function Body
  • 65. This functions can be called multiple times from different parts of your program, allowing you to reuse the same code logic
A) Function Body
B) Function Definition
C) Function Reusability
D) Function Call
  • 66. This method sorts the list in-place, meaning it modifies the original list
A) index()
B) sorted()
C) sort()
D) filter()
  • 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) Conditional Statement
D) If-else Statement
  • 68. This allow you to control the flow of execution in a program based on certain conditions.
A) If-else Statement
B) elif Statement
C) If Statement
D) Conditional 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) elif Statement
B) If-else Statement
C) Nested if Statements
D) If Statement
  • 70. This statement provides an alternative code block to execute if the condition is false.
A) If-else Statement
B) If Statement
C) Nested if Statements
D) elif Statement
  • 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) If-else Statement
C) Nested if Statements
D) If Statement
  • 72. This statement allows you to place an if statement inside another if statement to handle more complex conditions.
A) If Statement
B) elif Statement
C) Nested if Statements
D) If-else Statement
  • 73. This allows you to write a concise one-line if-else statement.
A) Logical Operator
B) Comparison Operator
C) Ternary Operator
D) Conditional Statement
  • 74. These are used to perform operations on Boolean values (True or False).
A) Comparison Operator
B) Logical Operator
C) Ternary Operator
D) Conditional Statement
  • 75. This operator returns True if both of the operands are True. Otherwise, it returns False.
A) and
B) equals
C) or
D) not
  • 76. This operator returns True if at least one of the operands is True. If both operands are False, it returns False.
A) not
B) or
C) and
D) equals
  • 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) equals
B) or
C) not
D) and
  • 78. This can optionally return a value using the return statement.
A) Function Definition
B) Return Value
C) Function Reusability
D) Function Call
  • 79. What this sign "==" means?
A) Not equal to
B) Greater than or equal to
C) Equal to
D) Less than or equal to
  • 80. What this sign "!=" means?
A) Equal to
B) Less than or equal to
C) Greater than or equal to
D) Not equal to
Students who took this test also took :

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