Kiruthikaramalingam commited on
Commit
7d02e86
·
verified ·
1 Parent(s): f30bc00

Update utils/quiz_utils.py

Browse files
Files changed (1) hide show
  1. utils/quiz_utils.py +67 -67
utils/quiz_utils.py CHANGED
@@ -1,67 +1,67 @@
1
- # Initialize quiz state
2
-
3
- quiz_questions = {
4
- "beginner": [
5
- {"question": "What is the correct syntax to print a message in Python?",
6
- "options": ["A. echo 'Hello'", "B. printf('Hello')", "C. print('Hello')", "D. write('Hello')"],
7
- "answer": "C. print('Hello')"},
8
- {"question": "What is a correct variable name in Python?",
9
- "options": ["A. 1variable", "B. variable1", "C. variable-1", "D. variable@1"],
10
- "answer": "B. variable1"},
11
- {"question": "Which of the following is a Python data type?",
12
- "options": ["A. list", "B. array", "C. stack", "D. queue"],
13
- "answer": "A. list"},
14
- {"question": "What does `len()` do in Python?",
15
- "options": ["A. Calculates length of a string or list", "B. Slices a list", "C. Joins strings", "D. Sorts a list"],
16
- "answer": "A. Calculates length of a string or list"},
17
- {"question": "What is the output of `print(type(10))`?",
18
- "options": ["A. int", "B. float", "C. str", "D. None"],
19
- "answer": "A. int"}
20
- ],
21
- "intermediate": [
22
- {"question": "Which keyword is used to handle exceptions in Python?",
23
- "options": ["A. catch", "B. handle", "C. try", "D. except"],
24
- "answer": "C. try"},
25
- {"question": "What is the result of `3 == 3.0` in Python?",
26
- "options": ["A. True", "B. False", "C. Error", "D. None"],
27
- "answer": "A. True"},
28
- {"question": "Which of the following is an immutable data type?",
29
- "options": ["A. List", "B. Tuple", "C. Dictionary", "D. Set"],
30
- "answer": "B. Tuple"},
31
- {"question": "What does the `join()` method do?",
32
- "options": ["A. Joins lists", "B. Joins elements of a list into a string", "C. Combines dictionaries", "D. Concatenates two strings"],
33
- "answer": "B. Joins elements of a list into a string"},
34
- {"question": "What does `list.pop()` do?",
35
- "options": ["A. Removes and returns the last element of the list", "B. Removes a random element", "C. Sorts the list", "D. Reverses the list"],
36
- "answer": "A. Removes and returns the last element of the list"}
37
- ],
38
- "advanced": [
39
- {"question": "What is the purpose of the `@staticmethod` decorator in Python?",
40
- "options": ["A. To define a method that doesn't require an instance",
41
- "B. To define a method that can modify a class attribute",
42
- "C. To define a method that requires an instance",
43
- "D. To define a private method"],
44
- "answer": "A. To define a method that doesn't require an instance"},
45
- {"question": "What is the time complexity of searching for an element in a dictionary?",
46
- "options": ["A. O(1)", "B. O(n)", "C. O(log n)", "D. O(n^2)"],
47
- "answer": "A. O(1)"},
48
- {"question": "What does the `zip()` function do in Python?",
49
- "options": ["A. Combines multiple iterables element-wise",
50
- "B. Compresses a list",
51
- "C. Converts a tuple into a dictionary",
52
- "D. Creates a list of pairs from two dictionaries"],
53
- "answer": "A. Combines multiple iterables element-wise"},
54
- {"question": "What is the difference between `deepcopy()` and `copy()`?",
55
- "options": ["A. `copy()` creates a shallow copy, `deepcopy()` creates a deep copy",
56
- "B. `copy()` is faster than `deepcopy()`",
57
- "C. `deepcopy()` is for strings only",
58
- "D. There is no difference"],
59
- "answer": "A. `copy()` creates a shallow copy, `deepcopy()` creates a deep copy"},
60
- {"question": "What does the `yield` keyword do?",
61
- "options": ["A. Returns multiple values from a function",
62
- "B. Converts a function into a generator",
63
- "C. Pauses a function and resumes it later",
64
- "D. Both B and C"],
65
- "answer": "D. Both B and C"}
66
- ]
67
- }
 
1
+ # Initialize quiz state
2
+
3
+ quiz_questions = {
4
+ "beginner": [
5
+ {"question": "What is the correct syntax to print a message in Python?",
6
+ "options": ["A. echo 'Hello'", "B. printf('Hello')", "C. print('Hello')", "D. write('Hello')"],
7
+ "answer": "C. print('Hello')"},
8
+ {"question": "What is a correct variable name in Python?",
9
+ "options": ["A. 1variable", "B. variable1", "C. variable-1", "D. variable@1"],
10
+ "answer": "B. variable1"},
11
+ {"question": "Which of the following is a Python data type?",
12
+ "options": ["A. list", "B. array", "C. stack", "D. queue"],
13
+ "answer": "A. list"},
14
+ {"question": "What does `len()` do in Python?",
15
+ "options": ["A. Calculates length of a string or list", "B. Slices a list", "C. Joins strings", "D. Sorts a list"],
16
+ "answer": "A. Calculates length of a string or list"},
17
+ {"question": "What is the output of `print(type(10))`?",
18
+ "options": ["A. int", "B. float", "C. str", "D. None"],
19
+ "answer": "A. int"}
20
+ ],
21
+ "intermediate": [
22
+ {"question": "Which keyword is used to handle exceptions in Python?",
23
+ "options": ["A. catch", "B. handle", "C. try", "D. except"],
24
+ "answer": "C. try"},
25
+ {"question": "What is the result of `3 == 3.0` in Python?",
26
+ "options": ["A. True", "B. False", "C. Error", "D. None"],
27
+ "answer": "A. True"},
28
+ {"question": "Which of the following is an immutable data type?",
29
+ "options": ["A. List", "B. Tuple", "C. Dictionary", "D. Set"],
30
+ "answer": "B. Tuple"},
31
+ {"question": "What does the `join()` method do?",
32
+ "options": ["A. Joins lists", "B. Joins elements of a list into a string", "C. Combines dictionaries", "D. Concatenates two strings"],
33
+ "answer": "B. Joins elements of a list into a string"},
34
+ {"question": "What does `list.pop()` do?",
35
+ "options": ["A. Removes and returns the last element of the list", "B. Removes a random element", "C. Sorts the list", "D. Reverses the list"],
36
+ "answer": "A. Removes and returns the last element of the list"}
37
+ ],
38
+ "advanced": [
39
+ {"question": "What is the purpose of the `@staticmethod` decorator in Python?",
40
+ "options": ["A. To define a method that doesn't require an instance",
41
+ "B. To define a method that can modify a class attribute",
42
+ "C. To define a method that requires an instance",
43
+ "D. To define a private method"],
44
+ "answer": "A. To define a method that doesn't require an instance"},
45
+ {"question": "What is the time complexity of searching for an element in a dictionary?",
46
+ "options": ["A. O(1)", "B. O(n)", "C. O(log n)", "D. O(n^2)"],
47
+ "answer": "A. O(1)"},
48
+ {"question": "What does the `zip()` function do in Python?",
49
+ "options": ["A. Combines multiple iterables element-wise",
50
+ "B. Compresses a list",
51
+ "C. Converts a tuple into a dictionary",
52
+ "D. Creates a list of pairs from two dictionaries"],
53
+ "answer": "A. Combines multiple iterables element-wise"},
54
+ {"question": "What is the difference between `deepcopy()` and `copy()`?",
55
+ "options": ["A. `copy()` creates a shallow copy, `deepcopy()` creates a deep copy",
56
+ "B. `copy()` is faster than `deepcopy()`",
57
+ "C. `deepcopy()` is for strings only",
58
+ "D. There is no difference"],
59
+ "answer": "A. `copy()` creates a shallow copy, `deepcopy()` creates a deep copy"},
60
+ {"question": "What does the `yield` keyword do?",
61
+ "options": ["A. Returns multiple values from a function",
62
+ "B. Converts a function into a generator",
63
+ "C. Pauses a function and resumes it later",
64
+ "D. Both B and C"],
65
+ "answer": "D. Both B and C"}
66
+ ]
67
+ }