Spaces:
Runtime error
Runtime error
Commit
·
2f3594f
1
Parent(s):
719bfc7
Update app.py
Browse files
app.py
CHANGED
@@ -109,6 +109,17 @@ for i in questions:
|
|
109 |
|
110 |
submit_button = Quiz.form_submit_button("Submit")
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
if submit_button:
|
113 |
for i, q in enumerate(questions): # This line was missing the enumeration
|
114 |
result = client.predict(
|
@@ -137,5 +148,5 @@ if submit_button:
|
|
137 |
x = x + 1
|
138 |
else:
|
139 |
x = x + 1
|
140 |
-
|
141 |
-
|
|
|
109 |
|
110 |
submit_button = Quiz.form_submit_button("Submit")
|
111 |
|
112 |
+
def calculate_average(numbers):
|
113 |
+
|
114 |
+
if numbers == []:
|
115 |
+
return "has not been calculated. Please finish the quiz to get your score."
|
116 |
+
numbers = [int(x) for x in numbers if isinstance(x, (int, str))]
|
117 |
+
|
118 |
+
|
119 |
+
total = sum(numbers)
|
120 |
+
average = total / len(numbers)
|
121 |
+
return f'is {average}'
|
122 |
+
|
123 |
if submit_button:
|
124 |
for i, q in enumerate(questions): # This line was missing the enumeration
|
125 |
result = client.predict(
|
|
|
148 |
x = x + 1
|
149 |
else:
|
150 |
x = x + 1
|
151 |
+
|
152 |
+
st.subheader(f'Your average score for your answers {calculate_average(scores)}')
|