Question: def price_increase(available_companies): Question 5 (solution can be written using multiple lines) You are a stock broker again. You have a list of Stock objects

def price_increase(available_companies): """ Question 5 (solution can be written using multiple lines) You are a stock broker again. You have a list of Stock objects (`available_companies`) that you allow to trade. At the end of the day, all the Stock objects you have, have increased in price by 1 dollar.

Make a deep copy of `available_companies`, and then for each Stock object in the deep copy, increase the trading_price by 1 dollar. Return this new list.

Example: >>> stonk1 = Stock("S&P 500", "SPY", 150.00, 150000) >>> stonk2 = Stock("NASDAQ", "QQQ", 200.00, 190000) >>> stonk3 = Stock("Gamestop Corp", "GME", 325.00, 480000) >>> original_stonks = [stonk1, stonk2, stonk3] >>> new_stonks = price_increase(original_stonks) >>> original_stonks[0] == new_stonks[0] # based on '==' which considers price False >>> original_stonks[0].trading_price + 1 == new_stonks[0].trading_price True >>> original_stonks[1].trading_price + 1 == new_stonks[1].trading_price True >>> original_stonks[2].trading_price + 1 == new_stonks[2].trading_price True """ pass

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve the problem of creating a function priceincrease that increases the trading price of each stock by 1 dollar you can follow these steps Step 1 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!