Question

Python: Stock Pricing The DOW Jones stock ticker has been on a roller coaster ride these...

Python: Stock Pricing The DOW Jones stock ticker has been on a roller coaster ride these past 12 months. A local hardware store has invested deeply into the bond market. In order for us to simulate any stock prices we can write a simple program using a list and either While or For loop to store 100 random values into each element in a list. Whenever you get a random number, you are assuming you have received the price of a stock that this hardware store is interested. You need to write a program that will randomly generate 100 different stock prices using a list ranged from (40 to 180) inclusive. Next, calculate the average stock price, the highest price, and the lowest price of the stocks in the list. Lastly, print out what you found.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshots of the code:

Sample output:

Code to copy:(Indent code properly with the help of screenshot)

import random
from statistics import mean

# function starts here
def stocks():
#create a listvariable list
list = []

#generate random numbers and append to list
for j in range(100):
list.append(random.randint(40, 180))

#Calculate and print the results
print("The randdomly generated 100 numbers are: \n")
print(list)
print("Highest stock price is: ")
print(max(list))
print("Lowest stock price is: ")
print(min(list))
print("Average of the all stocks prices is: ")
print(mean(list))

#main function to call the stock function
def main():
stocks()
#call to main
main()
  

Add a comment
Know the answer?
Add Answer to:
Python: Stock Pricing The DOW Jones stock ticker has been on a roller coaster ride these...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • THIS IS A PYTHON PROGRAM Part 1 – Stocks Research and Program Setup Find five (5)...

    THIS IS A PYTHON PROGRAM Part 1 – Stocks Research and Program Setup Find five (5) of your favorite stocks. In your research you will find the daily closing prices of those stocks from February 11, 2019 through February 15, 2019. Write prices out in a table (5 rows by 5 columns). Part 2 – Python Program Begin writing a Python program that will do the following: create a 2D list named stocks to store the data for each of...

  • Requires Python to answer A client wishes to keep track of his investment in shares. Write...

    Requires Python to answer A client wishes to keep track of his investment in shares. Write a program to help him manage his stock portfolio. You are to record both the shares that he is holding as well as shares that he has sold. For shares be is curreatly holding, record the following data: .a 3-character share code, share name, last purchase date, volume currently held and average purchase price (refer to description under part cii) option 2) For shares...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT