Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So in your main program, please accomplish the following: Run a one year simulation (eg play_trials (365)) through each random seed between 0 and 999.

So in your main program, please accomplish the following: Run a one year simulation (eg play_trials (365)) through each random seed between 0 and 999. Check which seed gives the highest profit. (you may use any pattern you prefer here) Print out that seed along with the profit. For example, my program has seed 795 giving the highest profit of $149,685. Again, yours will likely be different. To help you get started, here's a rough preview of what my python solution looks like. Ther solution looks very similar (the function definition syntax is different, but the organization is the same). import random # r people don't need to use any libraries def calculate_winnings (matches): def play_game () : def play_trials (trials): ...main program stuff... print (best_profit, best_seed) def play_trials(): x1 =

[] for i in range(5): y = random.randint(1,46) while(y in x1): y = random.randint(1,46) x1.append(y) 3 x2 [] for i in range(5): y = random.randint(1,46) ) while(y in x2): y = random.randint(1,46) x2.append(y) cnt = 0 for ele in x2: if ele in xl: cnt+=1 prize [0,1,15,200,150000] return prize(cnt] = def play_game ( ) : all_lottery [x for x in range(1, 46)] lottery random.sample(all_lottery, 5) lottery.sort() print('5

lottery numbers selected between 1 and 45'). guesses = [] print('User, please enter your 5 numbers.') for x in range(5): g = int(input(f'Enter guess {x+1}: ')) guesses.append(g) guesses.sort() def calculate_

winnings (lottery, guesses): matches = 0 for i in range (5): matches += 1 if lottery[i] guesses[i] else 0 print('Total matches:', matches) if matches == 0 or matches 1: return '$0' elif matches == 2: return '$1' elif matches 3: return '$15 elif matches 4: return '$200' else: return '$ 150,000 SO

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

2. Listen to family members, and solve problems with them.

Answered: 1 week ago