0

Very frustrating.

Wondering if someone can explain to me what I am doing wrong and show full working code? score1 = int(input()) score2 = int(input()) average = (score1+score2)/2 if (average > 0 and <= 69): print('0') elif (average <=70 and > 79) print("10") elif average <= 80 and > 89: print("30") elif average <= 90 and > 90: print("50") else: print("error") Thank you

14th Nov 2020, 7:13 PM
Alex
4 Answers
+ 3
"And" should connact two full boolean expressions, so the conditions in your code should be like this: average > 0 and average <= 69 Alternatively in python you can use double comparisons, so the previous line is equivalent to 0 < average <= 69 Note: in the current state the code will print 'error' when average == 69.5 (or even 75). You might want to fix that. Note 2: in both forms you don't need any parentheses in conditions
14th Nov 2020, 7:23 PM
Volodymyr Chelnokov
Volodymyr Chelnokov - avatar
0
thank you that makes a big part of it make sense! can you explain how i would fix the error? third day on the app
14th Nov 2020, 9:37 PM
Alex
0
You have to divide all the region of possible values of average into subrigions that don't overlap but together form the whole region For example (i don't know your problem, so i cannot say what will be the correct choice), if your average is between 0 and 100, you can take a) 0 <= average < 70 b) 70 <= average < 80 c) 80 <= average < 90 d) 90 <= average <= 100 You can just check these conditions. If you want to remove redundant comparisons, you can note that 0 <= average and average <= 100 should be always true by our suggestion (average between 0 and 100) also if we already did not fall into case a, then 70 <= average already holds, sp finally you'll get following code if average < 70: # case a elif average < 80: # case b elif average < 90: # case c else: # case d It is of course up to you to use the variant you consider to be more clear (full conditions or reduced conditions)
14th Nov 2020, 9:50 PM
Volodymyr Chelnokov
Volodymyr Chelnokov - avatar
0
score1 = int(input()) score2 = int(input()) average = (score1+score2)/2 if (average > 0 and average <= 69): print('0') elif (average <=70 and average > 79): print("10") elif (average <= 80 and average > 89): print("30") elif (average <= 90 and average > 90): print("50") else: print("error")
14th Nov 2020, 10:06 PM
**🇩đŸ‡Ș|🇩đŸ‡Ș**
**🇩đŸ‡Ș|🇩đŸ‡Ș** - avatar