Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.7 kB
4
Indexable
Never
def grading(num1, num2): #grades the points
    if num1 < 10:
        return 0

    total_num = num1 + num2

    if total_num >= 0 and total_num < 15:
        return 0
    elif total_num >= 15 and total_num < 18:
        return 1
    elif total_num >= 18 and total_num < 21:
        return 2
    elif total_num >= 21 and total_num < 24:
        return 3
    elif total_num >= 24 and total_num < 28:
        return 4
    elif total_num >= 28 and total_num <= 30:
        return 5

def num_converter(num2): #change num2 to points
    return num2 // 10

def grade_distribution(grade, grade_list): #print stars
    count = grade_list.count(grade)
    return '*' * count

def main(): #runs the main function
    exam_points = 0
    counter = 0
    grading_list = []
    pass_percent = 0

    while True:     #input from user
        exam_points_input = str(input("Exam points and exercises completed: "))
        if exam_points_input == "":
            break

        num1, num2 = exam_points_input.split()
        num1 = int(num1)
        num2 = int(num2)
        
        num2 = num_converter(num2)
        num2 = int(num2)
        total = num1 + num2
        grade = grading(num1, num2)

        grading_list.append(grade)
        if grade >= 1:
            pass_percent += 100
        exam_points += total
        counter += 1

    print("Statistics:")
    print(f"Points average:{exam_points / counter: .1f}")
    print(f"Pass percentage:{pass_percent / counter: .1f}")
    print("Grade distribution:")
    for i in range(5,-1,-1):
        print(f"  {i}: {grade_distribution(i, grading_list)}")




main()