What does this means ?? I can't understsnd?? | Sololearn: Learn to code for FREE!

+9

# 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)

1/31/2021 6:15:56 AM

K.S.S. Karunarathne

+26

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'

+18

Ipang Description is given wrong and unclear.

+9

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)

+7

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.

+6

XXX Done thanks for proper explanation.

+5

Thanks for the information sir.

+5

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)

+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.

+4

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.

+3

XXX How to use the tickets given in dictionary, where we have to multiply \$5 and \$20?

+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

+3

K.S.S. KARUNARATHNE please explain to me, about how to get value of old =530. Thanks

+3

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

+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

+2

XXX thank you man, your explanation helped me a lot!

+2

Yuniar Egi Prasasti The sum of the keys in the dictionary.

+1

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)

+1

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)

+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))

+1

Why we give int() in last line...🤔