Spaces:
Runtime error
Runtime error
Commit
·
bcb8663
1
Parent(s):
60d962b
Update app.py
Browse files
app.py
CHANGED
@@ -120,24 +120,24 @@ for i in questions:
|
|
120 |
else:
|
121 |
scores.append(f'N/A')
|
122 |
|
123 |
-
Quiz.form_submit_button("Submit")
|
124 |
-
|
125 |
-
x = 0
|
126 |
-
new_scores = []
|
127 |
-
for i in scores:
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
def calculate_average(numbers):
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
st.write(f'Your average score is {calculate_average(scores)}')
|
|
|
120 |
else:
|
121 |
scores.append(f'N/A')
|
122 |
|
123 |
+
res = Quiz.form_submit_button("Submit")
|
124 |
+
if res:
|
125 |
+
x = 0
|
126 |
+
new_scores = []
|
127 |
+
for i in scores:
|
128 |
+
if i == 'N/A':
|
129 |
+
scores.pop(x)
|
130 |
+
scores.append(85)
|
131 |
+
x = x+1
|
132 |
+
else:
|
133 |
+
x = x+1
|
134 |
+
|
135 |
+
def calculate_average(numbers):
|
136 |
+
if not numbers:
|
137 |
+
return 0 # Return 0 for an empty list to avoid division by zero.
|
138 |
+
|
139 |
+
total = sum(numbers)
|
140 |
+
average = total / len(numbers)
|
141 |
+
return average
|
142 |
+
|
143 |
+
st.write(f'Your average score is {calculate_average(scores)}')
|