This repository has been archived by the owner on May 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
minitask5.py
57 lines (51 loc) · 1.63 KB
/
minitask5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# minitask 5
# Define function add_question with 3 parameters:
# - index of the question that should be added
# - list of the pairs (question, list of possible answers)
# - the current quiz.
# The function selects the question with the index from the pool,
# adds it as the last item of the input quiz and returns the resulting quiz
# as the result. If no input quiz is provided when calling the add_question
# function, a new quiz with just the selected question is returned, so
# the default of the third parameter is thus an empty quiz.
def add_question(index, question_pool, quiz=None):
if quiz is None:
quiz = []
question = question_pool[index]
quiz.append(question)
return quiz
funcqpool = [
(
"If return statement is not used inside the function, the function will return:",
[
"0",
"None object",
"an arbitrary integer",
"Error! Functions in Python must have a return statement.",
],
),
(
"Which of the following function calls can be used to invoke function definition:\n def test(a, b, c, d):?",
[
"test(1, 2, 3, 4)",
"test(a = 1, 2, 3, 4)",
"test(a = 1, b = 2, c = 3, 4)",
"test(a = 1, b = 2, c = 3, d = 4)",
"test(1, 2, 3, d = 4)])",
],
),
]
funcquiz1 = [
(
"Which of the following keywords marks the beginning of the function block?",
[
"func",
"define",
"def",
"func",
],
)
]
print(add_question(0, funcqpool, funcquiz1))
print(funcquiz1)
print(add_question(0, funcqpool))