Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am gonna ask you to do this output { ' Special Special Prize': 0 , 'Special Prize': 1 , 'First Prize': 0 , 'Second

I am gonna ask you to do this output
{'Special Special Prize': 0, 'Special Prize': 1, 'First Prize': 0, 'Second Prize': 0, 'Third
Prize': 1, 'Fourth Prize': 0, 'Fifth Prize': 0, 'Sixth prize': 1,'No prize': 1}
Note: Sixth Prize 53977042, Third Prize 67921388, Special Prize
01260528
This is my code
def count_prizes(invoice):
# Define the prize lists
num =["59647042","01260528","01616970","69921388","53451508","710","042","633"]
special_prize_num0= num[0] # Special Award num(0)
special_prize_num1= num[2] # Special Prize num(1)
jackpot_num = num[3] # Jackpot num(2)
prize_counts ={
'Special Special Prize': 0,
'Special Prize': 0,
'First Prize': 0,
'Second Prize': 0,
'Third Prize': 0,
'Fourth Prize': 0,
'Fifth Prize': 0,
'Sixth prize': 0,
'No prize': 0
}
# Count prizes for each invoice
for ticket in invoice:
if ticket == special_prize_num0:
prize_counts['Special Prize']+=1
elif ticket == special_prize_num1:
prize_counts['Special Prize']+=1
elif ticket == jackpot_num:
prize_counts['First Prize']+=1
elif ticket[-6:]== jackpot_num[-6:]:
prize_counts['Second Prize']+=1
elif ticket[-6:]== jackpot_num[-6:]:
prize_counts['Third Prize']+=1
elif ticket[-5:]== jackpot_num[-5:]:
prize_counts['Fourth Prize']+=1
elif ticket[-4:]== jackpot_num[-4:]:
prize_counts['Fifth Prize']+=1
elif ticket[-3:]== jackpot_num[-3:]:
prize_counts['Sixth prize']+=1
else:
prize_counts['No prize']+=1
return prize_counts
# Example usage
invoices =["53977042","67921388","01260528","91132057"]
prize_counts = count_prizes(invoices)
print(prize_counts)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

3. Are our bosses always right? If not, what should we do?

Answered: 1 week ago

Question

Discuss the states of accounting

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago