Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please solve in Python Write a function that takes in a list of lists, where each inner list is of the above form (assume there

Please solve in Python

Write a function that takes in a list of lists, where each inner list is of the above form (assume there are always 3 elements in the inner list) and returns a dictionary where the keys are the labels for a slot machine (i.e. 1, 2 and 3) and the values are the total amount of money either won or lost for a particular slot machine:

{1: , 2: , 3: }

Notes:

If the input list is empty, then the dictionary values should be 0 for all slot machines.

You dont need to define magic numbers for the strings 1, 2, and 3. In general, we dont treat strings as magic numbers in this class.

def gambling_in_vegas(profit_history):

"""

>>> gambling_in_vegas ([[-123, -231, -82], [-340, -158, -225]])

{'1': -463, '2': -389, '3': -307}

>>> gambling_in_vegas([[-865, -342, 5]])

{'1': -865, '2': -342, '3': 5}

>>> gambling_in_vegas([[-954, -234, -235], [-1040, -350, -394], [-70, -43, -23]])

{'1': -2064, '2': -627, '3': -652}

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

Step: 3

blur-text-image

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 Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

Compare and contrast the four subdivisions of logistics management.

Answered: 1 week ago

Question

2. Outline the business case for a diverse workforce.

Answered: 1 week ago