Question: Hey there, so I tried to apply this code to my homework assignment multiple times, and the code passed 4 test and failed 3 tests.

Hey there, so I tried to apply this code to my homework assignment multiple times, and the code passed 4 test and failed 3 tests. I need this code to pass 5 tests, and I am stuck in finding the problem to my code here.

def correct_decision(current_shares,purchase_price,market_price,available_funds):

if market_price>purchase_price:

profit = current_shares*(market_price-purchase_price)

if profit>10:

print('Sell {} shares'.format(current_shares))

else:

print('Hold Shares')

if purchase_price>market_price:

remaining_funds = available_funds-10

if remaining_funds<=0:

print('Hold Shares')

else:

shares_can_be_bought = remaining_funds//market_price

print('Buy {} shares'.format(shares_can_be_bought))

correct_decision(10,100,1,10)

correct_decision(20,2,1,21)

correct_decision(15,12,1,12)

correct_decision(1,1,11,0)

correct_decision(10,1,3,30)

correct_decision(1,1,12,0)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Programming Questions!