P
P
Python Classroom
K

# Functions - return

example.py
Untitled
def main():
done = False
while not done:
print("D - Do Now")
print("Q - Quit")
print("e1 - Example1")
print("e2 - Example2")
print("e3 - Example3")
print("p1 - Problem1")
print("p2 - Problem2")
print("p3 - Problem3")
choice = input("Choice: ")
if choice == "D":
print("Do Now")
base=int(input("Base?"))
height=int(input("Height?"))
donow(base,height)
elif choice == "Q":
print("Exiting Game!")
done = True
elif choice == "e1":
base=int(input("Base?"))
height=int(input("Height?"))
area=e1(base,height)
print(area)
elif choice == "e2":
base=int(input("Base?"))
height=int(input("Height?"))
length=int(input("Length?"))
volume=e2(base,height,length)
print(volume)
elif choice == "e3":
x1=int(input("x1?"))
x2=int(input("x2?"))
y1=int(input("y1?"))
y2=int(input("y2?"))
slope=e3(x1,x2,y1,y2)
print(slope)
def donow(base,height):
print (base*height*1/2)
def e1(base,height):
return (base*height*1/2)
def e2(base,height,length):
return (base*height*length)
def e3(x1,x2,y1,y2):
return ((y2-y1)/(x2-x1))
main()
def main():
done = False
while not done:
print("D - Do Now")
print("Q - Quit")
print("e1 - Example 1")
print("e2 - Example 2")
print("e3 - Example 3")
choice = input("Choice: ")
if choice == "D":
print("Do Now")
base=int(input("Base?"))
height=int(input("Height?"))
donow(base,height)
elif choice == "Q":
print("Exiting Game!")
done = True
elif choice == "e1":
base=int(input("Base?"))
height=int(input("Height?"))
area=e1(base,height)
print(area)
elif choice == "e2":
base=int(input("Base?"))
height=int(input("Height?"))
length=int(input("Length?"))
volume=e2(base,height,length)
print(volume)
elif choice == "e3":
x1=int(input("x1?"))
x2=int(input("x2?"))
y1=int(input("y1?"))
y2=int(input("y2?"))
slope=e3(x1,x2,y1,y2)
print(slope)
def donow(base,height):
print (base*height*1/2)
def e1(base,height):
return (base*height*1/2)
def e2(base,height,length):
return (base*height*length)
def e3(x1,x2,y1,y2):
return ((y2-y1)/(x2-x1))
main()