0

Need help with this code pls 😅

This code should print a percentage, it's about the "growth analysis project" in the data structure of Python Here's the code 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()) take=0 for value in data.values(): if value <= age: take += 5 else: take += 20 percent=((take-515)/515)*100 print(int(percent )) I would appreciate all kind of help

30th May 2021, 9:23 PM
Jose Avila
Jose Avila - avatar
2 Antworten
+ 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()) new = old = 0 #initiating old & new revenue value for x in data.values(): #to calculate old revenue value i.e. age>18 = 20 & age<18 = 5 old += 5 if x < 18 else 20 for y in data.values(): #to calculate new revenue value new += 5 if y < age else 20 #if value is less than age revenue + 5 else + 20 if age < 18: print(int((new - old) / old * 100)) else: print(0)
30th May 2021, 10:53 PM
Manuel
Manuel - avatar
0
Hi Jose Avila Do you mean like this? Or is there another issue? Your question is a bit unclear. What is your input/ predicted output? https://code.sololearn.com/chSAn9K6vq3Q/?ref=app
30th May 2021, 10:44 PM
Ollie Q
Ollie Q - avatar