+ 2

Revenue growth analysis

Code is running but there is a small gap of no.s donno why? 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 count = 0 tcount= 0 for var in data.values(): if var >= 18: count += 5 else: count += 20 for var in data.values(): if var >= age: tcount += 5 else: tcount += 20 res = tcount-count res = res/tcount res = res *100 print(int(res

3rd Jun 2021, 3:53 PM
Harsh Jain
Harsh Jain - avatar
8 Réponses
+ 10
Harsh Jain , there has been some issues in the code: indentation problem, logic , ... see the reworked code in the file. please read it carefully to understand the modifications: https://code.sololearn.com/calf04pKPOwn/?ref=app
3rd Jun 2021, 6:57 PM
Lothar
Lothar - avatar
+ 2
def rev(age): revenue = sum([20 if x >= age else 5 for x in data.values()]) return revenue print(int(((rev(age)-rev(18))/rev(18))*100))
12th Nov 2021, 1:24 AM
Mateo González Bufi
Mateo González Bufi - avatar
+ 2
#Simple #Dont Repeat Yourself.. Look out this program... https://code.sololearn.com/cyP9MmTB50Rp/?ref=app
28th Aug 2022, 1:55 PM
Shaik Umar
Shaik Umar - avatar
+ 1
Harsh Jain and everyone willing to help: so i was not able to create the code at all because I dont fet the count and tcount parts. Specifically, I am having issues translating the task text into the code. I dont see why there are two iterations etc. Could someone pls explain? 😔😔
10th Oct 2021, 8:37 PM
Loai Wahdieh
+ 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 data_values = data.values() total = 0 stotal = 0 for x in data_values: if x >= 18: total += 20 else: total +=5 for x in data_values: if x >= age: stotal += 20 else: stotal += 5 res = ((stotal-total)/total)*100 print(int(res))
29th Oct 2021, 10:36 PM
Ahmed Abd El-Awal
0
Mina nader please remove print(total) and print(new_total) from the code.Then run the code and check.
25th Dec 2021, 3:14 AM
Dinesh Chavan
Dinesh Chavan - avatar
- 1
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:21 AM
Mina nader
Mina nader - avatar
- 1
This is my version in functional programming paradigm.... https://code.sololearn.com/c2xTaB112w37/?ref=app
12th Jul 2021, 6:49 PM
Azhar Faturohman Ahidin
Azhar Faturohman Ahidin - avatar