24k Magic, python beginner | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

24k Magic, python beginner

So I’ve been working on this for a minute but IM STUCK! My code is: purity = float(input()) if purity>75 and purity<83.2: print("18K") if purity>83.3 and purity<91.6: print("20K") if purity>91.7 and purity<99.8: print("22K") if purity>99.9: print("24K") And it runs great however, all the test cases are green and have a check mark except for test case #5, any ideas on what I did wrong I’m confused.

29th Jun 2021, 10:49 PM
Karma Hutchinson
Karma Hutchinson - avatar
12 Answers
+ 5
you don't provide output for these cases: purity <= 75 83.2 <= purity <= 83.3 91.6 <= purity <= 91.7 99.8 <= purity <= 99.9
29th Jun 2021, 11:02 PM
visph
visph - avatar
0
visph so what you’re saying is that i need to give an output for 75 and lower or am i not understanding
29th Jun 2021, 11:10 PM
Karma Hutchinson
Karma Hutchinson - avatar
0
I don't remember if task expect output for 75 and lower or if 75 must be included in 18K result... but you should surely provide output for all other cases ^^
29th Jun 2021, 11:12 PM
visph
visph - avatar
0
copy paste the task description if you want to be helped further ;P
29th Jun 2021, 11:15 PM
visph
visph - avatar
0
visph Thank you so mich, I’m new to coding and don’t know much about it but thanks https://sololearn.com/coach/1036/?ref=app
29th Jun 2021, 11:18 PM
Karma Hutchinson
Karma Hutchinson - avatar
0
the link doesn't work for me: copy paste the description, not the link ;)
29th Jun 2021, 11:25 PM
visph
visph - avatar
0
visph 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 Do not output anything, if the percentage is lower than 75%.
29th Jun 2021, 11:39 PM
Karma Hutchinson
Karma Hutchinson - avatar
0
if 75 <= purity < 83.3: print("18K") if 83.3 <= purity < 91.7: print("20K") if 91.7 <= purity < 99.9: print("22K") if 99.9 <= purity: print("24K")
29th Jun 2021, 11:43 PM
visph
visph - avatar
0
visph thanks, but how did you find that
29th Jun 2021, 11:44 PM
Karma Hutchinson
Karma Hutchinson - avatar
0
first list in decriprion give puriy for specific value (greater or equals), upper bound so is not included (strictly lesser)...
29th Jun 2021, 11:46 PM
visph
visph - avatar
0
visph i totally didnt think about that thank you so much
30th Jun 2021, 3:56 PM
Karma Hutchinson
Karma Hutchinson - avatar
- 1
Hello please someone gaid me how to use this apk
30th Jun 2021, 6:42 PM
Anas