0

Ticket Office problem in python

Hi guys I have a problem with the problem i mentioned in the title and i don't understand where i am making mistakes. so can anyone guide me? I've shared the code in the code playground too. 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()) sum1=sum2=0 for value in data.values(): if value >= age: value1 = value * 20 sum1+=value1 elif value < age: value2 = value * 5 sum2+=value2 cal=sum1+sum2 res=((cal-19590)/19590)*100 print(int(res))

3rd Mar 2021, 3:33 PM
Hatef Bahari Sani
Hatef Bahari Sani - avatar
15 Answers
3rd Mar 2021, 3:39 PM
Kaushik Patel
Kaushik Patel - avatar
+ 9
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 values = data.values() with_dis = 0 #Total money with discount. no_dis = 0 #Total money no discount. for i in values: if i in range(18): no_dis += 5 else: no_dis += 20 for k in values: if k < age: with_dis += 5 else: with_dis += 20 print(int(((with_dis - no_dis)/no_dis) * 100))
17th Jan 2022, 8:54 PM
IbrahimCPS
IbrahimCPS - avatar
+ 5
try this, that's the right answer ๐Ÿ‘Œ๐Ÿ‘Œ๐Ÿ‘Œ๐Ÿ‘Œ๐Ÿ‘Œโœ”โœ”โœ”โœ”โœ”โœ”โœ”โœจโœจโœจโœจโœจ๐Ÿ‘€๐Ÿ‘€๐Ÿ‘€๐Ÿ‘€๐Ÿ˜๐Ÿ˜๐Ÿ˜๐Ÿ˜๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ˜œ๐Ÿ˜œ๐Ÿ˜œ๐Ÿ˜„๐Ÿ˜„ don't waste your time 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 = 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 + 2
17th Aug 2021, 5:31 AM
ANDREW TSEGAYE
ANDREW TSEGAYE - avatar
+ 4
@kaushik, why old is 530 ?
18th Jun 2021, 7:05 AM
Saida Humbert
Saida Humbert  - avatar
+ 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 old_revenue = 0 new_revenue = 0 for value in data.values(): old_revenue += 20 if value >= 18 else 5 new_revenue += 20 if value >= age else 5 print(int((new_revenue - old_revenue)/old_revenue * 100))
7th Jun 2022, 4:54 AM
Yakhyokhuja Valikhujayev
Yakhyokhuja Valikhujayev - avatar
+ 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 print(int((new - old) / old * 100)) if age < 18 else print(0)
12th Sep 2022, 1:50 AM
Ahmmed Essam
Ahmmed Essam - avatar
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()) #your code goes here count1 = 0 count2 = 0 count3 = 0 count4 = 0 for values in data.values(): if values < 18: count1 += 1 else: count2 += 1 for values in data.values(): if values < age: count3 += 1 else: count4 += 1 profit1 = count1 * 5 profit2 = count2 * 20 profit3 = count3 * 5 profit4 = count4 * 20 profit_stand = profit1 + profit2 profit_dif = profit3 + profit4 diference = ((profit_dif - profit_stand) / profit_stand) * 100 print (abs(int(diference)))
8th Jul 2021, 3:18 PM
DENฤฐZ MUSTAFAOฤžLU
DENฤฐZ MUSTAFAOฤžLU - avatar
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()) count=0 d=0 new=0 old=0 p=530 for i in data.values(): if i < age: new+=5 else: old+=20 count+=1 d=new+old a=(d-p)/p w=a*100 print(int(w))
1st Nov 2022, 8:46 AM
ISMAEL YIMAM MOHAMMED
ISMAEL YIMAM MOHAMMED - avatar
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()) main = 0 new = 0 for original in data.values(): if original >= 18: main += 20 else: main += 5 main_total = main for change in data.values(): if change >= age: new += 20 else: new += 5 new_total = new Growth = (new_total - main_total) / main_total * 100 print(int(Growth))
19th Nov 2022, 12:34 AM
Mohamed Gomaa Soliman
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()) low_price = 5 high_price = 20 #your code goes here price_diff = high_price - low_price count_all= 0 for x in data.values(): count_all +=1 base_val = mod_val = 0 for x in data.values(): if x < 18: base_val += 5 else: base_val += 20 if x < age: mod_val += 5 else: mod_val += 20 print(int((mod_val-base_val)/base_val*100))
9th Jan 2023, 11:32 AM
Michaล‚
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()) #your code goes here l=0 for i in data.values() : if i >= 18 : l+=1 n=0 for g in data.values() : if g >= age : n+=1 lens=len(data) p1_low=(lens-l)*5 p2_low=(lens-n)*5 p1=(l*20)+p1_low p2=(n*20)+p2_low profit=((p2-p1)/p1)*100 print(int(profit))
25th Apr 2023, 10:23 AM
Pouria Ebneali
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()) #your code goes here l=0 for i in data.values() : if i >= 18 : l+=1 n=0 for g in data.values() : if g >= age : n+=1 lens=len(data) p1_low=(lens-l)*5 p2_low=(lens-n)*5 p1=(l*20)+p1_low p2=(n*20)+p2_low profit=((p2-p1)/p1)*100 print(int(profit))
25th Apr 2023, 10:24 AM
Pouria Ebneali
- 1
Hatef Bahari Sani Most Welcome ๐Ÿ‡ฎ๐Ÿ‡ณ๐Ÿ‡ฎ๐Ÿ‡ณ
3rd Mar 2021, 3:46 PM
Kaushik Patel
Kaushik Patel - avatar
- 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 def rev(age): i=0 j=0 for value in data.values(): if value>=age: i=i+1 elif value<age: j=j+1 x=(i*20)+(j*5) return x print(int(100*(rev(age)-rev(18))/rev(18)))
11th Oct 2021, 9:19 AM
Fahime Asgharnejad
Fahime Asgharnejad - avatar
- 2
@kaushik Thank you bro :X
3rd Mar 2021, 3:44 PM
Hatef Bahari Sani
Hatef Bahari Sani - avatar