return 0 <= grade <= 100
Returning true or false without me telling it to... python 3
-
19-10-2022 - |
Pergunta
I'm trying to figure this out. I want to enter a students grade into my program. The grade must be between 0 and 100.
I wrote the code that it returns False if grade is less than 0 or greater and 100, and told it to return True if the grade is less than 100 and greater than 0.
But how do I make my program return True and False, without telling it...return True, return False etc....
Cause I know when you type 2 == 2. It returns True without you telling it to.
grd=input("What is the grade?")
if (grd<0) or (grd>100):
return False
else:
return True
and
grd=int(input("Enter the grade please"))
while((0<=grd) and (grd<=100))!=True:
print("The grade is invalid. Please try again:")
grd=int(input("Grade please: "))
print("The grade is valid")
Nenhuma solução correta
Outras dicas
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow