+ 4

Pure gold.. pure frustration

I am on the pure gold task in python for beginners. It tells me my code is fine but it does not complete the requirement for test case 5. Unfortunately it won't let me see test case 5 to even know why it has a problem. purity = float(input()) if purity >= 91.7: print ("Accepted") if purity >= 99.9: print ("Accepted")

9th Mar 2021, 8:39 AM
Ryan Wright
Ryan Wright - avatar
23 Réponses
+ 2
Ryan Wright I'm not sure what theory you're referring to, but I can tell you without any doubt that it will pass if you just output "Accepted" for any purity that is greater than or equal to 91.7
9th Mar 2021, 9:12 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Ryan Wright You may try this: if float(input()) >= 91.7: print("Accepted") # Let me know if it fails
9th Mar 2021, 9:16 AM
Calvin Thomas
Calvin Thomas - avatar
+ 2
ChaoticDawg thank you. Removing second nested if statement did the trick. It feels like cheating doing it that way but the desired result with less code might be the lesson in this.
9th Mar 2021, 9:19 AM
Ryan Wright
Ryan Wright - avatar
+ 1
But what about 23K? 91.7 and more includes everything above 22K, including 23K. If that's the case, then: if float(input()) >= 91.7: print("Accepted")
9th Mar 2021, 8:58 AM
Calvin Thomas
Calvin Thomas - avatar
+ 1
Ryan Wright as Calvin Sheen Thomas has stated (sort of), all you need to do is remove your nested if statement. The reason you're failing is because if the purity is greater than or equal to 99.9 then "Accepted" is output twice instead of once.
9th Mar 2021, 9:05 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Calvin Sheen Thomas Excluding it will most likely fail. It should be as you've previously stated. I have submitted code and it passed.
9th Mar 2021, 9:14 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
purity = float(input( ) ) #your code goes here if purity >= 91.7: print("Accepted") if purity == 99.9: print("Accepted") This worked for me. Note: operator Description x == y equal to (same value)
21st Sep 2021, 6:41 PM
Arthur Best III
Arthur Best III - avatar
+ 1
purity = float(input()) if purity >= 91.7 and purity <=100: print ("Accepted")
28th Feb 2023, 6:38 AM
sahith p
sahith p - avatar
0
Could you please put the question here?
9th Mar 2021, 8:48 AM
Calvin Thomas
Calvin Thomas - avatar
0
thank you for replying. 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 There is an additional note at the bottom stating that less than 91.7 purity should output nothing. My code satisfied this requirement in test case #3.
9th Mar 2021, 8:51 AM
Ryan Wright
Ryan Wright - avatar
0
I like the theory, apparently 23k is 95.8% gold. Do you think they would throw a spanner in the works like that in a beginner course?
9th Mar 2021, 9:06 AM
Ryan Wright
Ryan Wright - avatar
0
If you want the 23K part to be excluded, then: a = float(input()) if 91.7 <= a < 95.8 or a >= 99.9: print("Accepted") # Apparently the indentation isn't being added
9th Mar 2021, 9:12 AM
Calvin Thomas
Calvin Thomas - avatar
0
Calvin Sheen Thomas the first code passed all accept for case 4 (it doesn't let me see the conditions) the second code failed all. Thank you for helping, I appreciate it.
9th Mar 2021, 9:30 AM
Ryan Wright
Ryan Wright - avatar
0
Ryan Wright is your problem solved?? If yes then please edit your question and write [SOLVED]. So you don't get same answers again
10th Mar 2021, 10:24 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
0
Hey, thats because we missed the logic where it says 99.9% and above! which means we need to mention above 99.9% not below! Assuming 100 is the benchmark,Try this code it will work! purity = float(input()) if purity >= 91.7 and purity <=100: print ("Accepted")
3rd May 2021, 6:30 PM
Sirisha Tammina
Sirisha Tammina - avatar
0
why task 5 is giving me an error + it is hidden
24th Jul 2021, 10:45 PM
omar
0
purity = float(input()) if purity >= 91.7: print("Accepted")
15th Aug 2021, 7:13 PM
Phirun Chhay
0
This worked for me purity = float(input()) x= 91.7 y= 100 if purity >=x and purity <=y: print("Accepted")
21st Aug 2021, 12:12 PM
Jofri Issac
Jofri Issac - avatar
0
#This is the correct code to this exercise purity = float(input()) if purity >= 91.7: print ("Accepted") elif purity >= 99.9: print("Accepted") else: print()
1st Sep 2021, 12:28 PM
Andy Elijah
Andy Elijah - avatar
0
this one is correct : purity = float(input()) if purity >= 91.7: if purity <=100: print ("Accepted")
4th Sep 2021, 3:11 PM
Anuva Islam
Anuva Islam - avatar