0
I have a doubt as when I enter the new age input as 10 it returns the output as 32, whereas the output should be 31.
The dictionary data consists of ticket numbers are keys and age as values. We need to find the current price which is when ticket for an adult is $20, while the ticket for a child under 18 is $5 and also for price where the we take new age input and use it as restrictions (adult > age > child). Output should be ( (new_ticket_price - old_ticket_price)/old_ticket_price * 100) This code works when I enter 16 as input. https://code.sololearn.com/cYsUM4EgPzB0/?ref=app
3 Antworten
+ 1
Hi! To get 31 with an input at 10, you have to change the lines:
if (value > 18):
….
to:
if value >= 18:
….
at two places in your code.
https://code.sololearn.com/cp5dKKDZ5PA9/?ref=app
+ 1
the math is correct. You get 515 and 680.
680 - 515 = 165
165 / 680 = 0.3203883495145
* 100 = 32.0388...
int() cuts all that off so it's 32
+ 1
Thanks Per Bratthammar ... It's working.