+ 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")
24 Answers
+ 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
+ 2
Ryan Wright You may try this:
if float(input()) >= 91.7:
print("Accepted")
# Let me know if it fails
+ 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.
+ 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")
+ 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.
+ 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.
+ 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)
+ 1
purity = float(input())
if purity >= 91.7 and purity <=100:
print ("Accepted")
0
Could you please put the question here?
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.
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?
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
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.
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
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")
0
why task 5 is giving me an error + it is hidden
0
purity = float(input())
if purity >= 91.7:
print("Accepted")
0
This worked for me
purity = float(input())
x= 91.7
y= 100
if purity >=x and purity <=y:
print("Accepted")
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()
0
this one is correct :
purity = float(input())
if purity >= 91.7:
if purity <=100:
print ("Accepted")