+ 12

What does this means ?? I can't understsnd??

You are analyzing sales data from a ticket office. The ticket for an adult is $20, while the ticket for a child under 18 is $5. The data you are given is in a dictionary format, where the keys are the sold ticket numbers, and the values are the customer ages. For example, "123-08": 24 means that the ticket was bought a 24 year old. Your goal is to calculate how much more money the office would make if it would change the ticket discount age to the given input. So, your program needs to take an integer as input and output the percentage of revenue growth, if the discount was given to people under that age. For example, if the office made $15000 with the original discount age, and would make $18000 with 14 as the discount age, then the growth would be ((18000-15000)/15000)*100 = 20% So, for the input 14, your program should output 20. The output should be an integer (use int() to convert the result)

31st Jan 2021, 6:15 AM
K.S.S. Karunarathne
K.S.S. Karunarathne - avatar
44 Respostas
+ 31
I Am AJ ! $5 and $20 don't have to be multiplied to anything. Also, don't get confused by the keys of the dictionary, that is, the ticket IDs. They have no significance in the problem. The things that matter are the dictionary values, that is, the ages of the customers. Ipang and AJ, Follow this: Define a variable, for now let's say 'original_total' = 0 Now loop through the *values* of the dictionary that represents the ages. If the age is < 18, add 5 to the `orig_total`, else add 20 Do you understand now how the total will be calculated? What you have to do is calculate the the total price of tickets sold. For each ticket, if the buyer's age < 18, 5 will be added to the total, else 20 will be added Then accept the input. Now you need to define another variable, for now let's say 'new_total', that represents the total with the new discount age. For each ticket, if buyer's age < input, add 5 to the total, else 20. Then calculate by how much percentage, 'new_total' is greater than 'orgininal_total'
31st Jan 2021, 9:06 AM
XXX
XXX - avatar
+ 21
Ipang Description is given wrong and unclear.
31st Jan 2021, 7:33 AM
A͢J
A͢J - avatar
+ 19
Ans: new = 0 old = 0 for x in data.values(): old += 5 if x < 18 else 20 for var in data.values(): new += 5 if var < age else 20 if age < 18: print(int((new - old) / old * 100)) else: print(0)
1st Jun 2021, 6:58 AM
Víctor Rodríguez Rios
Víctor Rodríguez Rios - avatar
+ 16
Do you mean something like this: 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 } age = int(input()) # your code goes here new = 0 old = 530 for var in data.values(): if var < age: new += 5 else: new += 20 if age < 18: print(int((new - old) / old * 100)) else: print(0)
31st Jan 2021, 9:42 AM
K.S.S. Karunarathne
K.S.S. Karunarathne - avatar
+ 8
Ipang the dictionary is already given in the code. K.S.S. KARUNARATHNE I Am AJ ! I'll try my best to explain By default, the discount age is 18, that is everyone below the age of 18 gets a discount (has to pay $5), while everyone else needs to pay the full $20. So first we need to calculate the total price of the tickets sold. Then, we have to recieve an input which will be the new discount age, that is, instead of 18, now everyone who is below the input age will get a discount. So if the input 16 is given, everyone below the age of 16 has to pay $5. Naturally, the total price of tickets sold will increase as now people of age 17 & 18 are also paying the full amount. We have to find the percentage of increase in price of total tickets sold.
31st Jan 2021, 7:52 AM
XXX
XXX - avatar
+ 8
XXX Done thanks for proper explanation.
31st Jan 2021, 9:53 AM
A͢J
A͢J - avatar
+ 6
I Am AJ ! Yes, I also have further doubts. 1. Where is the dictionary data, are we supposed to generate random data? 2. How many tickets were sold. To make $15000 revenue it takes a lot of tickets. 3 . I think the more there is people under specified age, the less the revenue. So if it comes to gaining, I think setting larger value for discounted age is in order.
31st Jan 2021, 7:42 AM
Ipang
+ 5
Thanks for the information sir.
31st Jan 2021, 9:54 AM
K.S.S. Karunarathne
K.S.S. Karunarathne - avatar
+ 5
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 } age = int(input()) # your code goes here new = 0 old = 530 for var in data.values(): if var < age: new += 5 else: new += 20 if age < 18: print(int((new - old) / old * 100)) else: print(0) for any answer follow me
22nd Apr 2021, 6:50 PM
Budhabhushan Waghmare
Budhabhushan Waghmare - avatar
+ 4
K.S.S. KARUNARATHNE Same problem for me also. Explanation is not proper here very confusing. Because of this I can't get Certificate.
31st Jan 2021, 7:32 AM
A͢J
A͢J - avatar
+ 4
K.S.S. KARUNARATHNE please explain to me, about how to get value of old =530. Thanks
20th Feb 2021, 9:56 AM
Yuniar Egi Prasasti
+ 3
XXX How to use the tickets given in dictionary, where we have to multiply $5 and $20?
31st Jan 2021, 7:56 AM
A͢J
A͢J - avatar
+ 3
XXX This is my tryout about it, but the OP didn't say this was about the course, and didn't include given code either. https://code.sololearn.com/cwQ09REAL82z/?ref=app
31st Jan 2021, 7:59 AM
Ipang
+ 3
age = int(input()) new = 0 old = 0 for x in data.values(): old += 5 if x < 18 else 20 for var in data.values(): new += 5 if var < age else 20 if age < 18: print(int((new - old) / old * 100)) else: print(0)
31st May 2021, 6:11 AM
Anushya Devi T.S PSGRKCW
Anushya Devi T.S PSGRKCW - avatar
+ 2
Focus on the second to last paragraph, there's the description of your task. Share your tryout code in the thread Description so people can see where you're stuck and assist you properly https://www.sololearn.com/post/75089/?ref=app
31st Jan 2021, 6:29 AM
Ipang
+ 2
XXX thank you man, your explanation helped me a lot!
18th Feb 2021, 1:43 AM
Diglett With Top Hat
Diglett With Top Hat - avatar
+ 2
Yuniar Egi Prasasti The sum of the keys in the dictionary.
20th Feb 2021, 11:12 AM
K.S.S. Karunarathne
K.S.S. Karunarathne - avatar
+ 2
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 } age = int(input()) new_price = 0 old_price = 0 for i in data.values(): old_price = old_price + 5 if i < 18 else 20 for j in data.values(): new_price = new_price + 5 if j < age else 20 if age < 18: print(int((new_price - old_price) / old_price * 100)) else: print(0)
18th Dec 2021, 7:52 AM
Abhishek Pandey
+ 1
age = int(input()) new = 0 old = 0 for val in data.values(): if val < age: new += 5 else: new += 20 for val in data.values(): if val < 18: old += 5 else: old += 20 print(int((new - old) / old * 100))
3rd Jun 2021, 4:06 PM
Priyanka Gujjari
Priyanka Gujjari - avatar
+ 1
Why we give int() in last line...🤔
26th Jun 2021, 4:57 AM
M R Joy
M R Joy - avatar