+ 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))
11 Answers
+ 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.
+ 5
Spaces are not used in variables creation.
total cost invalid
check again tax calculations. Should be counted on total. not on num value...
+ 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))
+ 5
Rainnn ,
use round(...)
+ 4
Rainnn ,
read my comments and rework the code.
+ 2
print(round(total_cost,2)) # here 2 means 2 decimal places.
+ 2
I solved it! Thanks so much for all the help!!
+ 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))
+ 1
how do I round to 2 decimal places?
+ 1
ok thank u!!
0
ok I'll try that tysm!!