Functions - one parameter
Parameter
Example 1
def main():
done = False
while not done:
print("Menu")
print("E1 - Example 1")
print("Q - Quit")
choice = input("Choice: ")
if choice == "E1":
num = int(input("Give me a number: "))
square(num)
elif choice == "Q":
print("Exiting Game!")
done = True
def square(num):
print(num, "squared is", num**2)
main()
Example 2
Example 3
Last updated
Was this helpful?