- 1. What method is used to append an item to the end of a list?
A) append() B) extend() 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) Exception handling B) Cleaning up Exception C) Exception Management D) With statement
- 3. How can you insert an element at a specific index in a list?
A) add() B) insert() C) append() D) extend()
- 4. This Removes and returns the element at a specified index.
A) delete() B) discard() C) pop() D) remove()
- 5. In Python, how can you add a new key-value pair to a dictionary?
A) Using update() B) Using add() C) Using insert() 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) Premature termination B) Short-circuit evaluation C) Sequential evaluation D) Direct 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) C) sorted_list = sorted(my_list, reverse=True) 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) lambda function B) map function C) def function D) Enumerate function
- 9. How is a function defined in Python?
A) Using the function keyword B) Using the def keyword C) Using the define keyword D) Using the define function
- 10. A string that enclosed in triple quotes that provides documentation for a function
A) Scope B) Docstring C) Parameters D) Arguments
- 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 count the total number 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 pop() B) Using discard() C) Using remove() D) Using clear()
- 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 key exists in a dictionary B) Checks if an element exists in a list C) Checks if a value is present in a set 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 locate() C) Using find() D) Using search()
- 16. Which method is used to merge the keys and values from one dictionary into another in Python?
A) combine() B) update() C) append() D) merge()
- 17. You can use a ______ to iterate over a list by manually managing an index variable.
A) While Loop B) List Comprehension C) For Loop D) Enumerate
- 18. A loop that is commonly used to iterate over the elements of a list.
A) While Loop B) Do While Loop C) Enumerate D) For 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, 2, 4, 6, 8] B) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] C) [0, 1, 2, 3, 4] D) [1, 3, 5, 7, 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) list function B) map 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) Cleaning up Exception B) Raising Exceptions C) With statement 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) 2 B) 4 C) 1 D) 3
- 24. This function can be used to create an iterator from elements of an iterable for which a function returns true.
A) filter() B) extend() C) index() 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 B) List unpacking C) sorted list D) Looping over list
- 26. How can you check if a specific element exists in a collection in Python?
A) Using the in operator B) Using verify() C) Using check() D) Using exists()
- 27. Which method is used to add elements from another set to a set in Python?
A) update() B) append() C) combine() D) merge()
- 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) List D) Enumerate
- 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) while B) iterate C) for 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) key B) compare C) sort D) extract
- 32. What keyword is used to reverse the order of elements in a list in Python?
A) invert B) sort C) reverse D) backward
- 33. How to adds an element to a set
A) Using append() B) Using add() 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) For Loop C) While Loop D) Enumerate
- 35. This is a block of reusable code that performs a specific task or set of tasks
A) Parameters B) Arguments C) Function D) Scope
- 36. A variables that is defined outside of any function have global scope and can be accessed from anywhere in the program
A) Parameters B) Docstring C) Arguments D) Scope
- 37. These are the values that the function expects to receive when it is called
A) Scope B) Parameters C) Arguments D) Variables
- 38. This refers to the values that are passed into a function when it is called.
A) Scope B) Variables C) Parameters D) Arguments
- 39. These are parameters in a function that have a default value specified in the function definition.
A) Keyword Arguments B) Positional Arguments C) Arbitrary Arguments D) Default Arguments
- 40. This allow you to pass a variable number of arguments to a function.
A) Keyword Arguments B) Positional Arguments C) Arbitrary 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) Keyword Arguments B) Default Arguments C) Arbitrary Arguments D) Positional Arguments
- 42. This is iterating through each element of the list and performing some operation on each element
A) Looping over list B) list unpacking C) for loop 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 Comprehension B) sorted list C) List unpacking D) Enumerate
- 44. A method to retrieve the value associated with a specific key.
A) extend() B) index() C) get() D) filter()
- 45. A function that returns a new sorted list from the elements of the original list. It does not modify the original list.
A) index() B) sort() C) sorted() 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 Strings B) Custom Sorting C) Sorting in Reverse Order 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) lambda C) Sorting Strings D) Reverse Sorting
- 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 Erick Santos B) Jann Santos C) Erick Santos D) Jann
- 50. How would you capitalize the first letter of each word in the string 'course'?
A) print(course.title()) B) print(course.upper()) C) print(course.capitalize()) D) print(course.lower())
- 51. Which of the following variable names is invalid?
A) _private_var B) courseName C) is_published 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[first]) C) print(course[0]) D) print(course[-1])
- 55. Which Python function returns the absolute value of a number?
A) abs() B) value() C) roundl() D) ciel()
- 56. Which function from the math module returns the smallest integer greater than or equal to a given number?
A) math.pow() B) math.floor() C) math.ceil() D) math.sqrt()
- 57. What is the result of the following code? x = "10" y = int(x) + 1 print(y)
A) 11 B) 101 C) 1 D) 10
- 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) Arguments C) variable names 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) Arbitrary Arguments C) Default Arguments D) Keyword Arguments
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) Handling Exception B) Exception Management C) Cleaning up 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 Body B) Function Reusability 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 Body B) Function Call C) Function Reusability 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 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 Definition B) Function Body C) Function Call D) Function Reusability
- 66. This method sorts the list in-place, meaning it modifies the original list
A) sorted() B) sort() C) index() D) filter()
- 67. This is used to compare two values. It allows you to determine the relationship between these values
A) If Statement B) If-else Statement C) Conditional Statement D) Comparison Operator
- 68. This allow you to control the flow of execution in a program based on certain conditions.
A) If Statement B) elif Statement C) If-else 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) Nested if Statements B) If-else Statement C) If Statement D) elif Statement
- 70. This statement provides an alternative code block to execute if the condition is false.
A) If-else Statement B) elif Statement C) Nested if Statements D) If 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) 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) Nested if Statements B) If-else Statement C) If Statement D) elif Statement
- 73. This allows you to write a concise one-line if-else statement.
A) Comparison Operator B) Logical Operator C) Conditional Statement D) Ternary Operator
- 74. These are used to perform operations on Boolean values (True or False).
A) Conditional Statement B) Ternary Operator C) Logical Operator D) Comparison Operator
- 75. This operator returns True if both of the operands are True. Otherwise, it returns False.
A) equals B) or C) and 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) or B) not C) equals D) and
- 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) not B) equals C) or D) and
- 78. This can optionally return a value using the return statement.
A) Function Reusability B) Function Definition C) Function Call D) Return Value
- 79. What this sign "==" means?
A) Equal to B) Greater than or equal to C) Not equal to D) Less than or equal to
- 80. What this sign "!=" means?
A) Greater than or equal to B) Equal to C) Less than or equal to D) Not equal to
|