+ 1
Kaleidoscopes Challenge: SOLVED
Hey folx, I'm trying to complete the Kaleidoscopes challenge. My code is giving the correct result, but because it's not rounding to two decimal places, I keep failing 3/5 tests. Can anyone help me figure out what's wrong? Challenge: https://www.sololearn.com/coach/44?ref=app My Solution: https://code.sololearn.com/cCq6UOU7k5Z4/?ref=app
12 Réponses
+ 4
It should be like this:
print(f'{total_cost * disc:.2f}')
I recommend you to go through the complete python tutorial, i am sure that this is mentioned there.
+ 3
If the purchase is 7, the result from your code is 33.705000000000005. So you have to round according the task description (if there is one), or use standard formatting output like f'{YourNumber:.2f}' with f-string.
+ 2
Wow, this makes zero sense to me and seems overly complicated for it's level. If the discount is 10% why are you using 0.09 and the Tax is 7%. Wouldn't the numbers be .10 for the discount and .07% for the tax.
+ 1
Lothar the task says the result should be rounded "to 2 decimal places", but I realised I don't know how to do that. I tried using the "round" function, but then I wasnt sure how to get the two decimal places using that either.
How would I use the f-string function in this case?
+ 1
print(round(yourdescription,2))
+ 1
Gkidan can you please explain the print statements… t,2 And the else print statement?
+ 1
Round the value of t to 2 decimal place
0
kalscp = 5.00
tax = 1.07
disc = 0.90
purchase = int(input())
total_cost = (purchase * kalscp) * tax
t=total_cost*disc
if purchase>1:
print(round(t,2))
else:
print(round(total_cost,2))
0
kalscp = 5.00
tax = 1.07
disc = 0.90
purchase = int(input())
total_cost = (purchase * kalscp) * tax
t=total_cost*disc
if purchase>1:
print(round(t,2))
else:
print(round(total_cost,2))
0
kscopeQ = int(input())
kscopeCost = 5
kscopeTotal = kscopeCost * kscopeQ
tax = kscopeTotal * 0.07
if kscopeQ>1:
discount = kscopeTotal * .10
kscopeWD = kscopeTotal - discount
kscopeWD += tax
print (kscopeWD)
elif kscopeQ<2:
kscopeTotal += tax
print (kscopeTotal)
This is my sesame street version. I keep getting the discounts scenarios wrong. Like if the input is 3 the answer is 14.45, yet I'm. Always off by 10 and I'll get 14.55 yet I checked the math in a calculator and I be getting 14.45. I'm thinking I have something in the wrong place and I can't see it. Need extra eyes.
0
TheKyMethod I'm getting the same, did you managed to fix your code?