Make your own block · in code: Functions
Makes your own block: a small flowchart with a name, that you can run again and again with a Call block. Like Start, it begins its own flowchart, and every path under it finishes at a Return.
addTax. A Call block runs it by this name.price, rate. Leave it empty if it needs none.Pet, to make a method: inside it, this is the object it runs on.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))price inside the function never mixes up a price in the main program.function in JavaScript, def in Python, a method in Java and C#.