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
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