samedi 24 avril 2021

How can I print variable which is int from while loop and if else in Python

The error I get from the program is undefined variable.

*

# Python 3.9.4
# import sys
# print(sys.version)

SubjectT = input("Enter your subject: ")
Tutor_Name = input("Enter your name: ")
Iterate = int(input("How many students are there? "))
# Set counter
# create count for each student
Accumulate = 0
for i in range(Iterate):  # It will run how many time based on Iterate input
    Score = float(input("Enter score: "))
    Counter = True
    while Counter:
        if 80 <= Score < 100:
            Accumulate1 = Accumulate + 1
        elif 80 > Score >= 65:
            Accumulate2 = Accumulate + 1
        elif 65 > Score >= 50:
            Accumulate3 = Accumulate + 1
        elif Score < 50:
            Accumulate4 = Accumulate + 1
        else:
            print("The number is a negative value or incorrect")
            Again = input("Enter yes for restarting again or if you want to exit the program please press anything: ")
            if Again in ("y", "Y", "YES", "Yes", "yes"):
                continue
            else:
                break
print(f"Subject title:", {SubjectT}, "\nTutor:", {Tutor_Name})
print("Grade", "     Number of students")
print("A", "Students: ", Accumulate1)
print("B", "Students: ", Accumulate2)
print("C", "Students: ", Accumulate3)
print("D", "Students: ", Accumulate4)

This is my first post in Stackoverflow. pardon me for any inappropriate content. Thanks you so much.

Aucun commentaire:

Enregistrer un commentaire