Finish a function · in code: Return Values
Finishes a function and goes back to the Call that ran it, giving back a value if you want.
price + tax.price + tax. Leave it empty to give nothing back.Open it in the editor, press Run, then change it and run it again.
def lineTotal(price, qty): cost = price * qty return cost
print("Stationery shop: pens ₹10 each, notebooks ₹45 each")pens = int(input("How many pens? "))pensCost = lineTotal(10, pens)books = int(input("How many notebooks? "))booksCost = lineTotal(45, books)total = pensCost + booksCostprint("Pens: ₹" + str(pensCost))print("Notebooks: ₹" + str(booksCost))print("Total to pay: ₹" + str(total))