Я работаю над назначением надписи на питоне.
90
или выше - A
и т. Д. И т. Д. Для остальной части букв; но когда значение вводится как отрицательное число, мне нужно, чтобы код ничего не делал, кроме как отображать error
.python: присвоение градации, отрицательное значение
Это то, что я пытался до сих пор:
#Design a Python program to assign grade to 10 students
#For each student, the program first asks for the user to enter a positive number
#A if the score is greater than or equal to 90
#B if the score is greater than or equal to 80 but less than 90
#C if the score is greater than or equal to 70 but less than 80
#D if the score is greater than or equal to 60 but less than 70
#F is the score is less than 60
#Ihen the program dispalys the letter grade for this student.
#Use while loop to repeat the above grade process for 10 students.
keep_going = 'y'
while keep_going == "y":
num = float(input("Enter a number: "))
if num >= 90:
print("You have an A")
elif num >= 80:
print("You have an 3")
elif num >= 70:
print("You have an C")
elif num >= 60:
print("You have an D")
elif (num < 60 and <= 0:
print ("You have an F")
else:
print("lnvalid Test Score.")
Что такое код? – zondo
Вы должны предоставить дополнительную информацию. – PRVS
Я голосую, чтобы закрыть этот вопрос как не относящийся к теме, потому что это не кодовая и учебная служба. – jonrsharpe