Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def calculate_performance(q1, q2, q3, q4, q5, q6): | |
| # Max marks for each quiz | |
| max_marks = [60, 60, 60, 60, 60, 80] | |
| # Weightage of each quiz in total percentage | |
| weightage = [5, 5, 10, 15, 15, 50] # in percentage | |
| # User scores | |
| scores = [q1, q2, q3, q4, q5, q6] | |
| percentage = 0 | |
| # Calculate weighted percentage | |
| for i in range(6): | |
| normalized = (scores[i] / max_marks[i]) * weightage[i] | |
| percentage += normalized | |
| percentage = round(percentage, 2) | |
| # Determine performance status | |
| if percentage >= 80: | |
| status = "Top Performer π " | |
| elif percentage >= 65: | |
| status = "Skilled Performer π" | |
| elif percentage >= 50: | |
| status = "Promising Performer π" | |
| else: | |
| status = "Needs Improvement π" | |
| return f"Total Percentage: {percentage}%", f"Performance Status: {status}" | |
| # Gradio UI components | |
| inputs = [ | |
| gr.Number(label="Quiz 1 Marks (out of 60)"), | |
| gr.Number(label="Quiz 2 Marks (out of 60)"), | |
| gr.Number(label="Quiz 3 Marks (out of 60)"), | |
| gr.Number(label="Quiz 4 Marks (out of 60)"), | |
| gr.Number(label="Quiz 5 Marks (out of 60)"), | |
| gr.Number(label="Quiz 6 Marks (out of 80)") | |
| ] | |
| outputs = [ | |
| gr.Textbox(label="Total Percentage"), | |
| gr.Textbox(label="Performance Status") | |
| ] | |
| app = gr.Interface( | |
| fn=calculate_performance, | |
| inputs=inputs, | |
| outputs=outputs, | |
| title="Quiz Performance Calculator", | |
| description="Enter your marks to see your total weighted percentage and performance status." | |
| ) | |
| app.launch() | |