Question: IN PYTHON 3 PLEASE! Hello everyone! First off, thank you for your time. I need help converting this program to use functions--I'm having a hard

IN PYTHON 3 PLEASE!

Hello everyone! First off, thank you for your time. I need help converting this program to use functions--I'm having a hard time understanding them completely. It MUST follow this form.

def main():

load() #to input the values

calc()

print()

#input num_stocks=int(input("How many stocks would you like to analyze?: ")) loops=0 for i in range(num_stocks): loops=loops+i stock_name=input("Enter stock name:") sh=int(input("Enter shares purchased: ")) pp=float(input("Enter purchase price: ")) sp=float(input("Enter stock selling price:")) comm=float(input("Enter broker commission as a percentage:")) print("-------------------------------------") #calc stock_bought=sh*pp broker_bought=stock_bought*comm stock_sold=sh*sp broker_sold=stock_sold*comm profit=(stock_bought+broker_bought)-(stock_sold-broker_sold) #output print("Stock name: ",stock_name) print("Amount paid on purchase: $",stock_bought) print("Amount paid to broker on purchase: $",broker_bought) print("Amount stock sold for: $",stock_sold) print("Amount paid to broker on sale: $",broker_sold) print("Account balance after sale: $",profit) print() print("Hope you made money!") 

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 Databases Questions!