50.
What are sets in A) Unordered collections of unique elements, B)
Python? Ordered collections of elements, C) Collections of
key-value pairs, D) Collections of lists
51. How do you create a set A) my_set = set(), B) my_set = {}, C) my_set = [], D)
in Python? my_set = set([])
52. What is the purpose of A) To count the occurrences of elements in an
the Counter class in iterable, B) To count the number of items in a list,
Python's collections C) To count the number of lines in a file, D) To count
module? the number of unique elements in a set
53. What is the difference A) Lists store all elements in memory at once, while
between a list and a generators produce elements on demand, B) Lists
generator? are immutable, while generators are mutable, C)
Lists are faster than generators, D) Generators are
only used for simple tasks
54. How can you use list A) By including a conditional expression within the
comprehensions to list comprehension, B) By using the filter() function,
filter elements from a C) By creating a new list and manually adding
list? elements, D) List comprehensions cannot be used
for filtering
55. What are some A) Processing large datasets, infinite sequences,
common use cases for and lazy evaluation, B) Creating simple loops, C)
generators in Python? Implementing data structures like stacks and
queues, D) Generating random numbers
56. What type of error does A) Syntax Error, B) Runtime Error
this code snippet have? (ZeroDivisionError), C) Semantic Error, D) No Error
x = 5; print(x); y = 2; z =
x / 0; print(z)
57. What type of error does A) Syntax Error, B) Runtime Error (IndexError), C)
this code snippet have? Semantic Error, D) No Error
numbers = [1, 2, 3];
print(numbers[3])
58. What type of error does A) Syntax Error, B) Runtime Error (IndexError), C)
this code snippet have? Semantic Error, D) No Error
my_list = [1, 2, 3];
my_list.append(4);
print(my_list.pop(5))
59. What type of error does A) Syntax Error, B) Runtime Error (RecursionError),
this code snippet have? C) Semantic Error, D) No Error
def factorial(n): if n ==
0: return 1; else: return
n * factorial(n); result =
factorial(5); print(result)
60. What type of error does A) Syntax Error, B) Runtime Error (IOError), C)
this code snippet have? Semantic Error, D) No Error
try: f =
open("myfile.txt", "r");
f.write("Hello!"); except
FileNotFoundError:
print("File not found.")
61. What type of error does A) Syntax Error, B) Runtime Error (KeyError), C)
this code snippet have? Semantic Error, D) No Error