Hello all first of all, nice forum.
I just joined today! In hopes to find some help to my coding errors, because I just started to learn python and I like it so far.
So I'm going directly to the matter. I'll first post what's the code expected to do and then what I have done so far.
Note the code worked fine but wasnt fully functional and now it seems a bit more broken as I tried to polish it against wrong typing from a potential user.
This code pretends to first fetch a number of students or a number of califications to be more precise, then proceeds to ask for the calification grade each time until reaching the number first specified in the code, and also does catch the lowest and highest grade of those entered, it also makes an average of the grades.
Sorry for the broken language, I'm not native. Please have some patience with me.
I have something like this:
I just joined today! In hopes to find some help to my coding errors, because I just started to learn python and I like it so far.
So I'm going directly to the matter. I'll first post what's the code expected to do and then what I have done so far.
Note the code worked fine but wasnt fully functional and now it seems a bit more broken as I tried to polish it against wrong typing from a potential user.
This code pretends to first fetch a number of students or a number of califications to be more precise, then proceeds to ask for the calification grade each time until reaching the number first specified in the code, and also does catch the lowest and highest grade of those entered, it also makes an average of the grades.
Sorry for the broken language, I'm not native. Please have some patience with me.
I have something like this:
Python:
def read_int():
while True:
try:
x = 0
sum_grades = 0
lowest_grade = 7
highest_grade = 1
students = int(input("Enter the number of students to evaluate: "))
counter = 0
while x < students :
try:
counter = counter + 1
students = students - 1
grade = float(input("Enter the grade of the student: "))
x = x + 1
if grade < 1 or grade > 7:
print("Please, enter a valid grade...")
break
else:
while True:
try:
sum_grades = sum_grades + grade
if lowest_grade >= grade :
lowest_grade = grade
if highest_grade <= grade :
highest_grade = grade
average = round(sum_grades / counter, 1)
print("The average is ", average )
print("Lowest grade ", lowest_grade )
print("highest grade ", highest_grade )
break
except ValueError:
print("Please, enter a numeral...")
print("")
except ValueError:
print("Please, enter a numeral...")
print("")
except ValueError:
print("Please, enter a numeral...")
print("")
read_int()