0

How do I modify the code to get an output of 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 def calculate_growth(original_data, new_discount_age): original_revenue = 0 new_revenue = 0 for ticket_number, age in original_data.items(): if age < 18: original_revenue += 5 else: original_revenue += 20 if age < new_discount_age: new_revenue += 5 else: new_revenue += 20 growth = ((new_revenue - original_revenue) / original_revenue) * 100

24th Apr 2023, 2:39 PM
ARBEIT MANN
ARBEIT MANN - avatar
5 Respostas
+ 5
First try to solve it and save your attempt on SL Playground.
24th Apr 2023, 4:23 PM
JaScript
JaScript - avatar
+ 5
TENGRANN SAN , there are some issues to fix: > variable name *age* is used for input the new age, but is also used in your for loop as loop variable. so it gets overwritten. use other name for input. > there is a function defined *calculate_growth()* but this function is never called and used. > there is no print() statement used to do the calculated output. > the output value has to be converted to int - see task description. try to rework the code.
24th Apr 2023, 8:55 PM
Lothar
Lothar - avatar
+ 2
Two important things to keep in mind when asking questions: 1. Ask what you really need to solve. The way to "get an output of 5" is to replace all code with "print(5)". So maybe that's not the question. 2. Instead of copying and pasting the code, add a link to the code in Code Playground. Use "+" button. Allows testing and debugging, and avoid copy errors.
24th Apr 2023, 11:38 PM
Emerson Prado
Emerson Prado - avatar
0
I did
24th Apr 2023, 8:00 PM
ARBEIT MANN
ARBEIT MANN - avatar
0
Ohk thnx
25th Apr 2023, 12:32 AM
ARBEIT MANN
ARBEIT MANN - avatar