Cprog Reviewer Finals (Python)
  • 1. What method is used to append an item to the end of a list?
A) extend()
B) append()
C) add()
D) insert()
  • 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) With statement
C) Exception Management
D) Exception handling
  • 3. How can you insert an element at a specific index in a list?
A) extend()
B) add()
C) insert()
D) append()
  • 4. This Removes and returns the element at a specified index.
A) discard()
B) remove()
C) pop()
D) delete()
  • 5. In Python, how can you add a new key-value pair to a dictionary?
A) Using insert()
B) Using update()
C) Using assignment()
D) Using add()
  • 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 = sort(my_list)
B) sorted_list = sorted(my_list, reverse=True)
C) sorted_list = sorted(my_list)
D) sorted_list = sort(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) def function
B) Enumerate function
C) lambda function
D) map function
  • 9. How is a function defined in Python?
A) Using the define function
B) Using the function keyword
C) Using the define keyword
D) Using the def keyword
  • 10. A string that enclosed in triple quotes that provides documentation for a function
A) Arguments
B) Docstring
C) Parameters
D) Scope
  • 11. What is the purpose of the enumerate() function in Python?
A) To remove specific elements from a list
B) To count the total number of elements in a list
C) To reverse the order of elements in a list
D) To iterate over both the elements and their indices 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 pop()
C) Using remove()
D) Using discard()
  • 13. Which method is used to delete a key-value pair associated with a specified key in a dictionary?
A) pop()
B) remove()
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 an element exists in a list
C) Checks if a substring is in a string
D) Checks if a key exists in a dictionary
  • 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) merge()
B) append()
C) update()
D) combine()
  • 17. You can use a ______ to iterate over a list by manually managing an index variable.
A) List Comprehension
B) For Loop
C) While Loop
D) Enumerate
  • 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, 5, 6, 7, 8, 9]
C) [1, 3, 5, 7, 9]
D) [0, 1, 2, 3, 4]
  • 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) Enumerate function
B) map 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) With statement
D) Raising Exceptions
  • 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) extend()
D) get()
  • 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) sorted list
C) List
D) Looping over list
  • 26. How can you check if a specific element exists in a collection in Python?
A) Using check()
B) Using exists()
C) Using verify()
D) Using the in operator
  • 27. Which method is used to add elements from another set to a set in Python?
A) combine()
B) merge()
C) update()
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) Sorted list
B) For Loop
C) Enumerate
D) List
  • 29. How can you define a function that takes two parameters in Python?
A) ef my_function(param1 - param2):
B) def 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) for
B) while
C) iterate
D) loop
  • 31. Which keyword is used to specify a function to extract a comparison key from each element for custom sorting in Python?
A) sort
B) key
C) extract
D) compare
  • 32. What keyword is used to reverse the order of elements in a list in Python?
A) sort
B) reverse
C) invert
D) backward
  • 33. How to adds an element to a set
A) Using add()
B) Using append()
C) Using extend()
D) Using insert()
  • 34. A function that allows you to loop over both the elements and their indices in a list.
A) List Comprehension
B) Enumerate
C) While Loop
D) For Loop
  • 35. This is a block of reusable code that performs a specific task or set of tasks
A) Scope
B) Parameters
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) Docstring
B) Scope
C) Parameters
D) Arguments
  • 37. These are the values that the function expects to receive when it is called
A) Scope
B) Variables
C) Parameters
D) Arguments
  • 38. This refers to the values that are passed into a function when it is called.
A) Parameters
B) Arguments
C) Variables
D) Scope
  • 39. These are parameters in a function that have a default value specified in the function definition.
A) Positional Arguments
B) Keyword Arguments
C) Arbitrary Arguments
D) Default Arguments
  • 40. This allow you to pass a variable number of arguments to a function.
A) Default Arguments
B) Arbitrary Arguments
C) Positional Arguments
D) Keyword Arguments
  • 41. These are specified by using the parameter names followed by an equals sign = and the value to be passed.
A) Default Arguments
B) Arbitrary Arguments
C) Positional Arguments
D) Keyword Arguments
  • 42. This is iterating through each element of the list and performing some operation on each element
A) list unpacking
B) sorting list
C) for loop
D) Looping over list
  • 43. This provide a concise way to create a new list by performing an operation on each element of an existing list.
A) sorted list
B) List unpacking
C) Enumerate
D) List Comprehension
  • 44. A method to retrieve the value associated with a specific key.
A) filter()
B) extend()
C) index()
D) get()
  • 45. A function that returns a new sorted list from the elements of the original list. It does not modify the original list.
A) sort()
B) sorted()
C) index()
D) filter()
  • 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) Sorting Strings
C) Custom Sorting
D) Reverse Sorting
  • 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) Reverse Sorting
C) lambda
D) Sorting Strings
  • 48. Which escape sequence is used to represent a newline in a string?
A) \'
B) \n
C) \"
D) \\
  • 49. What is the out put of this code first = "Jann Erick" last = "Santos" full = f"{first} {last}" print(full)
A) Jann
B) Jann Erick Santos
C) Jann Santos
D) Erick Santos
  • 50. How would you capitalize the first letter of each word in the string 'course'?
A) print(course.title())
B) print(course.capitalize())
C) print(course.lower())
D) print(course.upper())
  • 51. Which of the following variable names is invalid?
A) is_published
B) _private_var
C) 1st_name
D) courseName
  • 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[0])
B) print(course[1])
C) print(course[first])
D) print(course[-1])
  • 55. Which Python function returns the absolute value of a number?
A) abs()
B) ciel()
C) value()
D) roundl()
  • 56. Which function from the math module returns the smallest integer greater than or equal to a given number?
A) math.pow()
B) math.ceil()
C) math.floor()
D) math.sqrt()
  • 57. What is the result of the following code? x = "10" y = int(x) + 1 print(y)
A) 10
B) 101
C) 11
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) String
B) function
C) Arguments
D) variable names
  • 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) Arbitrary Arguments
B) Positional Arguments
C) Keyword Arguments
D) Default 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 handling
B) Handling Exception
C) Exception Management
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 Definition
B) Function Call
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 Call
B) Function Reusability
C) Function Body
D) Function Definition
  • 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 Definition
B) Function Body
C) Function Reusability
D) Function Call
  • 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 Call
C) Function Definition
D) Function Body
  • 66. This method sorts the list in-place, meaning it modifies the original list
A) index()
B) sort()
C) filter()
D) sorted()
  • 67. This is used to compare two values. It allows you to determine the relationship between these values
A) If Statement
B) Conditional Statement
C) Comparison Operator
D) If-else Statement
  • 68. This allow you to control the flow of execution in a program based on certain conditions.
A) If Statement
B) Conditional Statement
C) elif Statement
D) If-else 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) If Statement
B) Nested if Statements
C) elif Statement
D) If-else Statement
  • 70. This statement provides an alternative code block to execute if the condition is false.
A) Nested if Statements
B) elif Statement
C) If Statement
D) If-else 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) If Statement
B) If-else Statement
C) elif Statement
D) Nested if Statements
  • 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) If-else Statement
D) Nested if Statements
  • 73. This allows you to write a concise one-line if-else statement.
A) Ternary Operator
B) Conditional Statement
C) Comparison Operator
D) Logical Operator
  • 74. These are used to perform operations on Boolean values (True or False).
A) Ternary Operator
B) Comparison 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) or
B) not
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) or
B) not
C) and
D) equals
  • 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) Equal to
B) Not equal to
C) Less than or equal to
D) Greater than or equal to
  • 80. What this sign "!=" means?
A) Less than or equal to
B) Not equal to
C) Greater than or equal to
D) Equal to
Students who took this test also took :

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