Answer:
no_of_shares = int(input("Enter the number of shares: "))
purchase_price = float(input("Enter the purchase price of the stock: "))
sale_price = float(input("Enter the sale price of the stock: "))
total_stock_price = purchase_price*no_of_shares
total_spend_on_buying = total_stock_price + (0.03*total_stock_price)
total_sale_price = sale_price*no_of_shares
commission_while_selling = total_sale_price*0.03
net_gain_or_loss = total_sale_price - (total_spend_on_buying + commission_while_selling)
if(net_gain_or_loss<0):
print("After the transaction, you lost {} dollars".format(abs(net_gain_or_loss)))
else:
print("After the transaction, you made {} dollars".format(abs(net_gain_or_loss)))