File size: 1,565 Bytes
6fe8855
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()