0
Help python
data = { "100-90": 25, "42-01": 48, "55-09": 12, "128-64": 71, "002-22": 18, "321-54": 19, "097-32": 33, "065-135": 64, "99-043": 80, "111-99": 11, "123-019": 5, "109-890": 72, "132-123": 27, "32-908": 27, "008-09": 25, "055-967": 35, "897-99": 44, "890-98": 56, "344-32": 65, "43-955": 59, "001-233": 9, "089-111": 15, "090-090": 17, "56-777": 23, "44-909": 27, "13-111": 21, "87-432": 15, "87-433": 14, "87-434": 23, "87-435": 11, "87-436": 12, "87-437": 16, "94-121": 15, "94-122": 35, "80-089": 10, "87-456": 8, "87-430": 40 } s = 0 k = 0 age = int(input()) for i in data.values(): if age > i: s+= 20 else: s+= 5 if age > 18: k+=5 else: k+=20 print(int(s-k/2)*100) This my code i don't understand where my wrong
6 Answers
+ 1
The syntax of your code seems right and I get an output when I run it.
What are the expected output?
It's very important to put as much information as possible when asking a question
+ 1
I cannot guess what you are trying to do...
I have two questions for you:
1. What is the question/problem you are trying to solve
2. For a given input, what is the expected output
0
The expected output is 5, I have a lot of numbers outputs
0
You analyze the ticket sales data at the ticket office.
A ticket for an adult costs $20, while a ticket for children under 18 costs $5.
The data provided to you is stored in a dictionary format, where the keys are the numbers of tickets sold, and the values are the age of the buyers.
For example, "123-08": 24 means that this ticket was bought by a person aged 24.
Your goal is to calculate how much money the cashier would earn if they changed the age for the discount to the one passed as input.
Thus, your program should take an integer as input and output the percentage of income growth if the discount would be given to people younger than this age.
For example, if the cashier earned $15,000 at the initial age of the discount, and earned $18,000 at the age of the discount at 14, then the increase would be ((18000-15000)/15,000)*100 = 20%
Therefore, with input data that is 14, your program should output 20. The output must be an integer (use i
0
My output is 11500, expected 5
0
I've done it like this:
https://code.sololearn.com/cCjujJLaO58O/?ref=app