Programming-Challenges/29 Validation/exercise-01.py
2026-08-31 12:48:25 +01:00

42 lines
1.2 KiB
Python

def get_score():
""" asks for test score """
collect = True
while collect:
test_score = input("Enter test score: ").strip()
if test_score.isnumeric():
test_score = int(test_score)
if test_score >= 0 and test_score <= 100:
collect = False
else:
print("Invalid input. Please enter a number between 0 and 100.")
else:
print("Invalid input. Please enter a number.")
return test_score
def main():
""" runs all functions """
test_score = int(get_score())
print("These are the GSCE grade boundaries:")
if test_score >= 90:
print("Your grade is 9")
elif test_score >= 80:
print("Your grade is 8")
elif test_score >= 70:
print("Your grade is 7")
elif test_score >= 60:
print("Your grade is 6")
elif test_score >= 50:
print("Your grade is 5")
elif test_score >= 40:
print("Your grade is 4")
elif test_score >= 30:
print("Your grade is 3")
elif test_score >= 20:
print("Your grade is 2")
else:
print("Your grade is 1")
main()