Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 2 : In this part, you will use a dictionary to store sector information about each company. Your code should read the companyList.txt file.
Part :
In this part, you will use a dictionary to store sector information about each company. Your code
should read the companyList.txt file. You will also use a dictionary that uses the company name
as a key and a tuple with its sector and stock price as the stored value.
Firstly, copy
ppy and rename the copy to py
Your
ppy program will accomplish the following:
Initialize an empty dictionary, named companydict
Populate the dictionary with the companies found in companyList.txt using the company
name as a key and the value as a tuple of Sector Stock Price
a For example: Ford: Auto Google: Software
The user will be presented the number of unique sectors listed. The user will then
prompt to enter a number that corresponds to a given sector, or to exit the program.
a Your program should reprompt the user for an invalid number input eg greater
than or less than
b Your program does not need to implement edge cases for nonnumber inputs
When the user selects a sector, the companies that are attached to that sector and their
stock price will be displayed.
Your new "main menu" output should look something like this:
Welcome to the Generic Finance App!
There are sectors companies
: Finance
: Semiconductor
: Software
: Conglomerate
: Retail
: Defense
: il
: Auto
: FMCG
To exit the program, type "EXIT"
select a sector to see its companies and its current stock market price:
The menu includes a list of all sectors followed by a request for a choice input.
Use the entered number to identify the selected sector. Search through the dictionary and print
out all companies associated with the sector. Your output should appear as follows:
To exit the program, type "EXIT"
select a sector to see its companies and its current stock market price:
Selected sector: Auto
GM stock:
Ford stock:
Toyota stock:
Tesla stock:
Stellantis stock:
Volkswagen stock:
Honda stock:
Press enter to continue...
Step 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