+ 1

Python 24k magic

DeSCRIPTION Now that we know how to combine multiple conditions, let’s improve our gold purity checker program and output the corresponding purity level in Karats! Here is the purity chart we’ll be using: 24K – 99.9% 22K – 91.7% 20K – 83.3% 18K – 75.0% If the percentage is between 75 and 83.3, the gold is considered to be 18K. If it's between 83.3 and 91.7 - then it’s 20K, and so on. Given the percentage as input, output the corresponding Karat value, including the letter K. Sample Input: 92.4 Sample Output: 22K

17th Feb 2021, 7:27 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
5 odpowiedzi
+ 2
Kim Hammar-Milliner Based on the problem description, Shouldn't the first condition be 99.9 and not 99.99?
17th Feb 2021, 8:42 AM
noteve
noteve - avatar
+ 1
it is solved now.
17th Feb 2021, 8:48 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
0
here is my code and it still fails on the last test case purity = float(input()) if purity >= 99.99: print("24K") elif purity >= 91.7: print("22K") elif purity >= 83.3: print("20K") elif purity >= 75.0: print("18K")
17th Feb 2021, 7:29 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
0
Kim Hammar-Milliner how? cant get the last one to work
21st Mar 2021, 6:31 PM
Zach Z
0
it is already solved
21st Mar 2021, 8:44 PM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar