Input Value Out of Range
Input Value Out of Range
Wonder with the request. "If the score is out of Range, print an Error".
How to get the condition out of range if the following variables are >= 0.9(A) and < 0.6(F).
Write a program to prompt for a score between 0.0
and 1.0. If the score is out of range, print an
error. If the score is between 0.0 and 1.0, print
a grade using the following table:
Score Grade
>= 0.9 A
>= 0.8 B
>= 0.7 C
>= 0.6 D
< 0.6 F
If the user enters a value out of range, print a
suitable error message and exit. For the test,
enter a score of 0.85.
so far the code I created was working for keying score, however I still don't get how to create the condition "out of range", could you help me? thanks
– Eddy Evodius Hieronimus
5 mins ago
here the code I made: score = float(input( "Enter Score: ")) b = 0.9 c = 0.8 d = 0.7 e = 0.6 f = 1 if score >= b: print("A") elif score >= c: print("B") elif score >= d: print("C") elif score >= e: print("D") elif score < d: print("F") else: print("error")
– Eddy Evodius Hieronimus
5 mins ago
Just add this -> if score < 0 or score > 1: print 'Out of range'. Thats it. For Grade A check if score > 0.9 and < 1, For F check if score > 0 and < 0.6
– yogi
3 mins ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
What have you tried so far?
– Luca Cappelletti
9 mins ago