Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def calculate_performance(q1, q2, q3, q4, q5, q6):
|
| 4 |
+
# Max marks for each quiz
|
| 5 |
+
max_marks = [60, 60, 60, 60, 60, 80]
|
| 6 |
+
# Weightage of each quiz in total percentage
|
| 7 |
+
weightage = [5, 5, 10, 15, 15, 50] # in percentage
|
| 8 |
+
|
| 9 |
+
# User scores
|
| 10 |
+
scores = [q1, q2, q3, q4, q5, q6]
|
| 11 |
+
percentage = 0
|
| 12 |
+
|
| 13 |
+
# Calculate weighted percentage
|
| 14 |
+
for i in range(6):
|
| 15 |
+
normalized = (scores[i] / max_marks[i]) * weightage[i]
|
| 16 |
+
percentage += normalized
|
| 17 |
+
|
| 18 |
+
percentage = round(percentage, 2)
|
| 19 |
+
|
| 20 |
+
# Determine performance status
|
| 21 |
+
if percentage >= 80:
|
| 22 |
+
status = "Top Performer π
"
|
| 23 |
+
elif percentage >= 65:
|
| 24 |
+
status = "Skilled Performer π"
|
| 25 |
+
elif percentage >= 50:
|
| 26 |
+
status = "Promising Performer π"
|
| 27 |
+
else:
|
| 28 |
+
status = "Needs Improvement π"
|
| 29 |
+
|
| 30 |
+
return f"Total Percentage: {percentage}%", f"Performance Status: {status}"
|
| 31 |
+
|
| 32 |
+
# Gradio UI components
|
| 33 |
+
inputs = [
|
| 34 |
+
gr.Number(label="Quiz 1 Marks (out of 60)"),
|
| 35 |
+
gr.Number(label="Quiz 2 Marks (out of 60)"),
|
| 36 |
+
gr.Number(label="Quiz 3 Marks (out of 60)"),
|
| 37 |
+
gr.Number(label="Quiz 4 Marks (out of 60)"),
|
| 38 |
+
gr.Number(label="Quiz 5 Marks (out of 60)"),
|
| 39 |
+
gr.Number(label="Quiz 6 Marks (out of 80)")
|
| 40 |
+
]
|
| 41 |
+
|
| 42 |
+
outputs = [
|
| 43 |
+
gr.Textbox(label="Total Percentage"),
|
| 44 |
+
gr.Textbox(label="Performance Status")
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
app = gr.Interface(
|
| 48 |
+
fn=calculate_performance,
|
| 49 |
+
inputs=inputs,
|
| 50 |
+
outputs=outputs,
|
| 51 |
+
title="Quiz Performance Calculator",
|
| 52 |
+
description="Enter your marks to see your total weighted percentage and performance status."
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
app.launch()
|