0

I stuck in "Revenue Growth Analysis" in Python Data Structure

Hi, I'm trying to solve Revenue Growth Analysis Project in Python Data Structure. I don't understand why I try the example (In project description) and It's actually 20%. But I don't know where 15000$ and 18000$ come from. Can someone explain? My code: https://code.sololearn.com/cwNQKiZIfall/?ref=app

3rd Feb 2021, 12:34 AM
Satakun Utama
Satakun Utama - avatar
6 Antworten
+ 8
Satakun Utama I think I was a little off earlier, it is 20$ rather than 20% discount. But here is your code: The problem is the second for loop, it is checking if equal to that age when it should be greater or equal, if >= age then add 20$ else add 5$. Second, the program dont need to check if tcount is larger than count vice versa, you can just compare the two right away, to get negative values. If you have more questions, please feel free to ask. Thanks. Here's your code: https://code.sololearn.com/cXUADCKg410k/?ref=app
3rd Feb 2021, 1:25 AM
noteve
noteve - avatar
+ 3
Satakun Utama , 15000 and 18000 are just some numbers to demonstrate how they can be used in the formula given. but they have no real relation to the values in the data dict sample. In addition to the method described (for loop and incrementing / summing variables), there are also other ways that can be applied to solve the task. if you are familiar with dicts, you could use a dict comprehension with a filter condition ( >=18) to get the number of tickets sold with regular price. together with the number of total items sold, it is possible to get the numbers of tickets sold with reduced price. it would be also possible to use the filter function with the data dict and a filter condition to get the numbers required for the final calculation. so with 6 lines of code the task is done. happy coding!
4th Feb 2021, 7:09 PM
Lothar
Lothar - avatar
+ 3
Hey, make count = 1 and tcount = 1 then it will work, I hope
17th Apr 2021, 5:41 AM
Barsha Dash
Barsha Dash - avatar
+ 1
age = int(input()) #your code goes here def z (y): count=0 count1=0 for x in data.values(): if x < y: count += 1 else: count1 += 1 return (count *5) + (count1 *20) print(int((z(age)-z(18))/z(18) *100))
6th Jun 2021, 1:25 PM
jordan fletcher
0
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()) teen = 0 lista = 0 for value in data.values(): if value < 18: teen += 1 for value in data.values(): if value < age: lista += 1 total_tickets = len(data) menores_edad = teen mayores_edad = total_tickets - teen original_price = 20 * mayores_edad + 5 * menores_edad menores_lista = lista mayores_lista = total_tickets - menores_lista total_price_discount = 5 * menores_lista + 20 * mayores_lista print(int((( total_price_dis
19th Apr 2021, 2:55 PM
Russell Masimba
Russell Masimba - avatar
0
This is my attempt so far , i don't know why it is considered wrong ? total = 0 data = data.values() for age in data: if age < 18: total += 5 else: total += 20 print (total) user_age = int(input()) new_total = total for age in data: if age < user_age: new_total += 5 else: new_total += 20 print (new_total) revenue_growth = (new_total / total )*100 print (revenue_growth)
1st Jul 2021, 11:20 AM
Mina nader
Mina nader - avatar