Question
This is python assignment!!! From the data file stock.txt, you are required to create a dictionary, myDict, containing four keys: stockNames, dates, openPrices and closePrices,
This is python assignment!!!
From the data file stock.txt, you are required to create a dictionary, myDict, containing four keys: stockNames, dates, openPrices and closePrices, and then from myDict find out the stock names that increased their prices on that day. The values of these dictionary keys are lists named names, dates, openPrices and closePrices, respectively. Each line of the text of stock.txt represents the values for stock name, date, stock open price, stock high price, stock low price, stock close price, stock volume and stock price adjacent to close, respectively. Extract text from the first line, line by line, to populate these four lists so that the list names contains the stock names, the list dates contains the dates of trading, the list openPrices contains stock open prices, and the list closePrices contains the stock close prices. Display the fours lists and leave a blank line between your outputs, in the form similar to the following (same for the rest unless otherwise specified): The list names is: ['ABC', 'DEF', 'GHI']Use Python built-in functions to create myDict with a single statement. Display myDict. After that, create a list, increasedStocks, to hold the stock names that increased their prices on that day (hint: use a for loop to populate the list). Lastly, display the content of increasedStocks, with the following format:The stocks that increased their prices are ABC, DEF, ..., XYZ.
here is the txt:
ASP 2001-12-31 12.55 12.8 12.42 12.8 11300 6.91 AVA 2000-10-12 19.0 19.0 17.88 18.31 233900 13.5 ATU 2001-04-30 15.49 15.49 15.09 15.23 511600 3.77 ARG 2001-12-20 15.45 15.5 15.05 15.06 464900 14.1 AEO 2001-05-02 39.52 39.75 38.25 39.2 3399300 11.85 APL 2001-10-05 23.35 24.0 23.31 24.0 13500 12.69 AFG 2001-07-11 29.44 30.05 29.25 30.02 197700 16.98 APD 2001-11-28 45.37 45.87 45.16 45.39 348900 38.18 ADI 2001-02-26 44.5 45.15 42.0 43.21 3509100 38.3 ARM 2001-11-14 15.5 16.1 15.5 16.01 336200 13.14 AM 2000-08-21 19.06 19.25 18.5 18.87 169400 15.45 AZN 2000-06-15 42.06 42.06 41.56 41.62 154700 30.24 APC 2001-05-04 61.5 62.81 61.3 62.06 4983800 29.03 AWF 2001-04-23 8.9 8.94 8.85 8.9 283700 3.92 AAP 2001-12-07 43.75 44.0 43.4 44.0 215100 14.3 AOI 2001-05-03 9.03 9.07 9.0 9.07 53400 7.6 AIV 2001-06-28 47.85 48.3 47.85 48.02 211900 19.48 ASR 2001-11-23 13.8 13.8 13.45 13.55 26900 9.13 ACS 2001-05-30 69.99 72.3 69.49 71.86 854600 35.93 ARW 2001-04-23 25.85 25.85 24.86 25.1 606900 25.1 ACV 2000-07-12 30.87 30.87 30.19 30.56 112800 7.18
4. (30 points) From the data file stock.txt, you are required to create a dictionary, myDict, containing four keys: stockNames, dates, openPrices and closePrices, and then from myDict find out the stock names that increased their prices on that day. The values of these dictionary keys are lists named names, dates, openPrices and closePrices, respectively. Each line of the text of stock.txt represents the values for stock name, date, stock open price, stock high price, stock low price, stock close price, stock volume and stock price adjacent to close, respectively. Extract text from the first line, line by line, to populate these four lists so that the list names contains the stock names, the list dates contains the dates of trading, the list openPrices contains stock open prices, and the list closePrices contains the stock close prices. Display the fours lists and leave a blank line between your outputs, in the form similar to the following (same for the rest unless otherwise specified): The list names is: ['ABC', 'DEF', 'GHI'] Use Python built-in functions to create myDict with a single statement. Display myDict. After that, create a list, increasedStocks, to hold the stock names that increased their prices on that day (hint: use a for loop to populate the list). Lastly, display the content of increasedStocks, with the following format: The stocks that increased their prices are ABC, DEF, ..., XYZStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started