Python for Beginners Boolean Logic 24k Magic | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
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.

21st Feb 2022, 4:43 PM
Jens Kopsch
+ 2
99.9
21st Feb 2022, 4:44 PM
Simba
+ 2
You have two 99.99 values in conditions.
21st Feb 2022, 4:59 PM
Simba
+ 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")
21st Feb 2022, 5:29 PM
Per Bratthammar
0
Hi! Do you know you can write a >= b and a < c as b <= a < c ? What happend โelseโ ?
21st Feb 2022, 4:50 PM
Per Bratthammar
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 ๐
21st Feb 2022, 4:54 PM
Jens Kopsch
0
Thank you, your Code is working well. ๐
21st Feb 2022, 8:00 PM
Jens Kopsch
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....
17th Sep 2022, 1:08 AM