+ 2

Hi people!! I'm trying to solve the kaleidoscopes coding challenge. Can someone pls tell me what's wrong with my code?

num = int(input()) if num>1: num = num - 0.1*num total cost = 5*num + 0.07*num print (float(total cost))

1st May 2023, 5:03 PM
Rainnn
Rainnn - avatar
11 odpowiedzi
+ 6
Rainnn , additional to the incorrect naming of the variable, 2 other issues has to fixed: > the discount is currently calculated from the >number of items<. this is not correct. it should be calculated from the costs of >number of items * price< > the final output has to be >rounded to 2 decimal places<. currently a float conversion is used. this has to be corrected.
1st May 2023, 7:12 PM
Lothar
Lothar - avatar
+ 5
Spaces are not used in variables creation. total cost invalid check again tax calculations. Should be counted on total. not on num value...
1st May 2023, 5:34 PM
Jayakrishna 🇮🇳
+ 5
You forget to put _ between total_cost Python don't accept spaces in variables. That the function code: num = int(input()) if num>1: num = num - 0.1*num total_cost = 5*num + 0.07*num print (float(total_cost))
1st May 2023, 5:34 PM
Kill Book
Kill Book - avatar
+ 5
Rainnn , use round(...)
1st May 2023, 7:21 PM
Lothar
Lothar - avatar
+ 4
Rainnn , read my comments and rework the code.
1st May 2023, 7:19 PM
Lothar
Lothar - avatar
+ 2
print(round(total_cost,2)) # here 2 means 2 decimal places.
1st May 2023, 7:22 PM
Jayakrishna 🇮🇳
+ 2
I solved it! Thanks so much for all the help!!
1st May 2023, 7:25 PM
Rainnn
Rainnn - avatar
+ 1
Can someone pls tell me what to do after this? Thanks!! num = int(input()) if num>1: num = num - 0.1*num total_cost = 5*num total_cost = total_cost + 0.07*total_cost print (float(total_cost))
1st May 2023, 7:15 PM
Rainnn
Rainnn - avatar
+ 1
how do I round to 2 decimal places?
1st May 2023, 7:20 PM
Rainnn
Rainnn - avatar
+ 1
ok thank u!!
1st May 2023, 7:24 PM
Rainnn
Rainnn - avatar
0
ok I'll try that tysm!!
1st May 2023, 7:21 PM
Rainnn
Rainnn - avatar