Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem #3: A Stock Market Investment (10 points) You have purchased 20 shares of a single stock for $200 a share, for a total cost

image text in transcribedimage text in transcribed

Problem \#3: A Stock Market Investment (10 points) You have purchased 20 shares of a single stock for $200 a share, for a total cost of $4000. Simulate the price fluctuations of this stock. Each day, the price can go up or down by one, two or three dollars or remain the same. To get a random change, you can import the random module and then run the following statement in your program, which will randomly choose one of the integers between -3 and 3. change = random. randint (3,3) Use a while loop to simulate changing the stock price each day over however many days it takes until the price either falls below $150 or above $250. If you lost money (the price fell below $150 ), give the number of days that have elapsed, the phrase "You cut your losses" and the amount of your loss. If you made money (the price went above $250 ), give the number of days that have elapsed, the phrase "You cashed out" and the amount of your gain. No user input is required. Following are two sample runs of the program. You may get different results due to randomness. 751 days have elapsed. The final price was $252. You cashed out. You made $1040. 280 days have elapsed. The final price was $148. You cut your losses. Problem \#5: Statistics on the Number of Days Elapsed (Optional, Extra Credit, 10 Points) Remove all the output from problem \#3. Then wrap it in another loop that runs it 1000 times. Considering the number of days elapsed during each of the 1000 runs, what was the maximum number of days of all the runs? The minimum number? The average number? Grading: Five points correct logic, three points correct output, two points comments Note: extra credit only counts toward your assignments grade, and your assignments grade cannot exceed 100%. So doing this extra credit will only help you if you lose points somewhere else on this assignment or another assignment

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

ISBN: 1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

What does the phrase to buy the market mean?

Answered: 1 week ago

Question

What are the potential downsides to firm growth?

Answered: 1 week ago

Question

Compute the maximum . 1. MINIMUM Computing the min 1st ail - / C Si

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago