0
Python for Beginners Boolean Logic 24k Magic
I can't solve Hidden Test Case 7, this ist my Code: purity = float(input()) if (purity >= 75.0) and (purity < 83.3): print ("18K") elif (purity >= 83.3) and (purity < 91.7): print ("20K") elif (purity >= 91.7) and (purity < 99.99): print ("22K") elif (purity >= 99.99): print ("24K") Thank's for Help.
7 odpowiedzi
+ 2
99.9
+ 2
You have two 99.99 values in conditions.
+ 1
# You can compare with this one:
purity = float(input())
if 75.0 <= purity < 83.3:
print("18K")
elif 83.3 <= purity < 91.7:
print("20K")
elif 91.7 <= purity < 99.9:
print("22K")
elif 99.9 <= purity <= 100.0:
print("24K")
0
Hi! Do you know you can write
a >= b and a < c
as
b <= a < c
?
What happend ’else’ ?
0
I know this, but is more easy to read for me. I changed the 99.99 to 99.9 but the Test Case 7 is anymore red 😔
0
Thank you, your Code is working well. 😀
0
This quiz is wrong. Your code is correct, but the SoloLearn test 7 will flag it as incorrect, look at what I changed on my last statement that gave me a green pass:
purity = float(input())
if purity >= 75 and purity < 83.3:
print("18K")
elif purity > 83.3 and purity < 91.7:
print("20K")
elif purity > 91.7 and purity < 99.9:
print("22K")
else:
print("24K")
....
How does an else statement at the end make any sense? I input "55" and the result was "24K" yet I passed....