Question: Write a program called the stocks.py that has the following features: A- A getStocks function that gets from the user two lists, one containing the
Write a program called the "stocks.py" that has the following features: A- A getStocks function that gets from the user two lists, one containing the list of stock names and the second containing the list of stock prices. This should be done in a loop such that it keeps on getting a stock name and price until the user enters the string 'done' as a stock name. The function should return both lists. B- A searchStock function that takes three input parameters: the stockNames list, the stockPrices list and the string to search for s. It returns a single value pertaining to the found price. Note that if the stock name (s) is not found in the stockNames list, then the function should return the value -1 as the stock price. C- The printStock function takes three input parameters: the stockNames list, the stockPrices list and a price value p. The function should print the names of stocks whose price is higher than p. If there are no values higher than p, then the function should print nothing. Note that this function returns nothing.
D- The main function calls the other functions described above to get the lists of stock names and prices, asks the user to enter the name of a stock to search for, and prints the stocks whose price is higher than the given stock price.
In total, the program should have four functions: getStocks, searchStock, printStock and main. Make sure to support your code with comments explaining what it does.
Your output will look something like this:
Please use IDLE Python code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
