I didn't know where else to put this since there is no subforum for python..
So i'm trying to make a program with the goal of computing the average for test marks for a class of students and somehow record what the maximum mark entered was.
The thing that kind of confuses me is that there is no set number of marks that is going to be entered. As soon as a mark that is not between 0 and 100 is entered the program will stop asking for more marks.. so every time the program is run it could be that someone enters 23 different legitimate marks or 40 legitimate marks for example.
How do I make it so the program stops asking for marks after a number not between 0 and 100 is entered? This is what I have tried:
However this doesn't work. All this does is opens up the program and prompts the user to enter a mark. After a mark is entered, it will ask for a mark again, and again, and again, never stopping (even if the mark entered is below 0 or above 100) What did I do wrong? In the program I did while the mark is less than or equal to 100 and greater than or equal to 0 run the main function again. So say if a negative number of a number greater than 100 is entered shouldn't the main function not be run again?
To go even further.. how would sum up all of the marks entered as a running total as they are entered? The reason being because I will need to know to find out the average at the end.
And how would I determine what the max mark entered was?
I've read through my whole book but nothing is in it about this stuff.. help/guidance would be greatly appreciated.
So i'm trying to make a program with the goal of computing the average for test marks for a class of students and somehow record what the maximum mark entered was.
The thing that kind of confuses me is that there is no set number of marks that is going to be entered. As soon as a mark that is not between 0 and 100 is entered the program will stop asking for more marks.. so every time the program is run it could be that someone enters 23 different legitimate marks or 40 legitimate marks for example.
How do I make it so the program stops asking for marks after a number not between 0 and 100 is entered? This is what I have tried:
def main():
mark = input("Enter the student's mark: ")
while mark <= 100 and mark >= 0:
main()
# Calling the main function.
main()
However this doesn't work. All this does is opens up the program and prompts the user to enter a mark. After a mark is entered, it will ask for a mark again, and again, and again, never stopping (even if the mark entered is below 0 or above 100) What did I do wrong? In the program I did while the mark is less than or equal to 100 and greater than or equal to 0 run the main function again. So say if a negative number of a number greater than 100 is entered shouldn't the main function not be run again?
To go even further.. how would sum up all of the marks entered as a running total as they are entered? The reason being because I will need to know to find out the average at the end.
And how would I determine what the max mark entered was?
I've read through my whole book but nothing is in it about this stuff.. help/guidance would be greatly appreciated.


