24k Magic, python beginner | Sololearn: Learn to code for FREE!

+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.

6/29/2021 10:49:31 PM

Karma Hutchinson

12 Answers

New Answer

+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

0

visph so what you’re saying is that i need to give an output for 75 and lower or am i not understanding

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 ^^

0

copy paste the task description if you want to be helped further ;P

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

0

the link doesn't work for me: copy paste the description, not the link ;)

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%.

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")

0

visph thanks, but how did you find that

0

first list in decriprion give puriy for specific value (greater or equals), upper bound so is not included (strictly lesser)...

0

visph i totally didnt think about that thank you so much

-1

Hello please someone gaid me how to use this apk