- 2

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. Here is my code, but unfortunately its not working. purity = float(input()) if purity >= 99.9: print('24k') elif purity >= 91.7: print('22k') elif purity >= 83.3: print('20k') elif purity >= 75: print('18k')

23rd Jun 2021, 7:10 PM
Sanchit Bahl
Sanchit Bahl - avatar
7 Answers
+ 2
just remember python is case sensitive language... You're welcome....
23rd Jun 2021, 7:25 PM
Jayakrishna 🇮🇳
+ 3
visph I agree... Language case sensitivity would apply to things like variable and function names or class names, etc. However, here, case sensitivity applies to string character comparisons. These are fundamentally different concepts.
24th Jun 2021, 3:54 AM
David Carroll
David Carroll - avatar
+ 2
All you need Capital K in 24K, 22K .. instead of small k.
23rd Jun 2021, 7:20 PM
Jayakrishna 🇮🇳
+ 1
Thats exactly what happens, when a commerce student start learning a computer language from the scratch 😜. Anyways thanks for your help man !
23rd Jun 2021, 7:25 PM
Sanchit Bahl
Sanchit Bahl - avatar
+ 1
Sanchit Bahl What's a "commerce student"?
24th Jun 2021, 3:49 AM
David Carroll
David Carroll - avatar
+ 1
visph yes. that's not a noticeable mistake using of "small k" in string. But after op reply I guess he/she is new to coding and also may came here after knowing html. That's my guess that time so I added case sensitivity info. So next time he care about it similar cases of strings, by himself... output is user defined but there it's is problem description defined. Is not it? also it was additional information some what related ...
24th Jun 2021, 7:14 PM
Jayakrishna 🇮🇳
0
Jayakrishna🇮🇳 is right when he said "python is case sensitive language"... however, that's not related with the problem here: upper/lower case mistake happen inside string... and so in output... unfortunatly, test check for exact output (case sensitive), rather than checking for output without matter if upper/lower case: here the case sensitivity is not related with the language case sensitivity ^^
24th Jun 2021, 3:13 AM
visph
visph - avatar