If statement | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

If statement

You’re making a gold purity checker, that should accept only 22K or 24K gold. Only the good stuff! 22K gold has 91.7% or more gold in it, while 24K corresponds to 99.9% and above purity. Given the % of gold purity as input, you should output "Accepted" only if it corresponds to 22 or 24K. Sample Input: 93.4 Sample Output: Accepted And my code is... ==================== purity=float(input()) if 91.7<=purity and 99.9>=purity: print ("Accepted") ====================

30th Mar 2021, 6:47 AM
Kathiravan P
Kathiravan P - avatar
8 Answers
0
No keep trying. One more hint, it says 24k gold corresponds to 99.9% and above. Your code STOPS at 99.9% meaning if the purity is 99.99% it will not be accepted by your code. Change it so it accepts anything above 99.9% or just lose that bit of code alltogether.
30th Mar 2021, 7:13 AM
Slick
Slick - avatar
+ 2
Try this ! It's working . purity = float(input()) if purity >= 91.7 and purity <=100: print ("Accepted")
26th Aug 2021, 3:58 PM
Harpreet kaur
0
gold that is 99.99999% gold will be rejected by your code. I'd just leave the first condition and it should work.
30th Mar 2021, 6:56 AM
Slick
Slick - avatar
0
Can you please tell me the code.
30th Mar 2021, 7:04 AM
Kathiravan P
Kathiravan P - avatar
0
This is my code. But its not working on test case 5 ------------------------------------- purity = float(input()) if purity >= 91.7: print ("Accepted") if purity >= 99.9: print ("Accepted") if purity >= 99.99999: print ("Not Accepted") ----------------------------------------
16th Aug 2021, 12:32 AM
Ahmed Ayman Soliman
Ahmed Ayman Soliman - avatar
0
purity = float(input()) if purity >= 91.7: print ("Accepted") it works for all test case
19th Oct 2021, 6:11 PM
PREETHIMADHURI TAPATI
0
purity = float(input()) #your code goes here if purity >= 91.7: print ("Accepted") elif purity >= 99.9: print ("Accepted")
4th Feb 2022, 8:09 AM
Christos Perrakis
Christos Perrakis - avatar
- 1
The first 4 test cases are passed but the lastone 5th hidden testcase was failed. I can't identify what is the bug in the code any one please help me to move on next step.
30th Mar 2021, 6:49 AM
Kathiravan P
Kathiravan P - avatar