Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Names = {} Prices = {} Exposure = {} symbol = input('What is the stock symbol?') def addName(): name_symbol = input('What is the name?') Names[name_symbol]

Names = {} Prices = {} Exposure = {} symbol = input('What is the stock symbol?')

def addName(): name_symbol = input('What is the name?') Names[name_symbol] = symbol

def addPrices(): buyPrice = input('What is the buy price?') currentPrice = input('What is the current price?') Prices[buyPrice] = currentPrice

def addExposure(): risk = input('What is the current risk of the stock?') shares = input('What is the current shares of the stock?') Exposure[risk] = shares

def main(): name1, name2 = input('Please enter two more stock names.').split() buyPrice1, buyPrice2 = input('Please enter two more buy prices for each corresponding name').split() price1, price2 = input('Please enter two more current prices for each corresponding name.').split() risk1 , risk2 = input('Please enter two more risk chances for each corresponding name.').split() exposure1, exposure2 = input('Please enter two more shares for each corresponding name.').split() Names[name1] = name2 Prices[buyPrice1] = price1 Prices[buyPrice2] = price2 Exposure[exposure1]= risk1 Exposure[exposure2] = risk2

def addStock(): addName() addPrices() addExposure() main() addStock() print(Names) print(Prices) print(Exposure)

using this code that i coded can someone help me with part 2 please.

Note! Your program does not need to check for valid floating point user input; if the program crashes because of this no points will be deducted. However, there is code below that you may use to validate input to be sure that the input is valid. First, you will need to add the following function:

GetSale - Finds the maximum expected value of selling a stock. The expected sale value of a stock is the current profit minus the future value of the stock:

Expected Sale value = ( ( Current Price - Buy Price ) - Risk * CurrentPrice ) * Shares

The GetSale function should calculate this value for each stock in the portfolio, and return the stock symbol with the highest expected sale value.

Main - Change/update/add the main function. This should take no arguments, but present a menu item consisting of "1. Add Stock", "2. Recommend Sale" and "3. Exit". If the user selects '1,' the Add Stock function is called, and when it is complete, the menu is presented again. If the user selects '2,' the Symbol of the stock corresponding to the highest expected value (returned by GetSale) should be displayed, and the menu presented after completion. If the user selects '3', the program should end.

Be sure to use comments for both structure of the program and documentation of the code.

All code must completely be your own individual work product.

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions