I'm learning Python, and I've made a couple of simple mathematical programs and I'm wanting to combine the two scripts. Here's the two seperate programs:
Code:
def multiply():
def intro():
print "Yo bitches, I can multiply. Wanna watch?"
intro()
def inputs():
n1=input("What's the first number?: ")
n2=input("Now gimme the second number: ")
p=n1*n2
print "I just did it, motherfucker. The answer is", p, "units."
inputs()
def again():
again=raw_input("Are you going to mathematically rape me again?(y or n): ")
if again=='y':
print inputs()
if again=='Y':
print inputs()
if again=='n':
print "Fuck, and I was looking forward to that."
if again=='N':
print "Fuck, and I was looking forward to that."
again()
multiply()
Code:
def circle():
def intro():
print "Welcome to my circumference finder!"
intro()
def main():
r=input("What is the radius of the circle? ")
c=r*r*3.14
print "The circumference is", c, "units"
again=raw_input("Do you want to do another calculation? (y or n) ")
if again=='y':
print main()
elif again=='Y':
print main()
else:
print "Good bye"
main()
circle()
So I tried combining the two like this.
Code:
def choose():
print "1. Multiply numbers"
print "2. Find the circumference of a circle"
choice=raw_input("Choose which program you would like to use: ")
if choice=='1':
print multiply()
elif choice=='2':
print circle()
else:
print "Please choose a valid option"
print choose()
choose()
def multiply():
def intro():
print "Yo bitches, I can multiply. Wanna watch?"
intro()
def inputs():
n1=input("What's the first number?: ")
n2=input("Now gimme the second number: ")
p=n1*n2
print "I just did it, motherfucker. The answer is", p, "units."
inputs()
def again():
again=raw_input("Are you going to mathematically rape me again?(y or n): ")
if again=='y':
print inputs()
if again=='Y':
print inputs()
if again=='n':
print "Fuck, and I was looking forward to that."
if again=='N':
print "Fuck, and I was looking forward to that."
again()
multiply()
def circle():
def intro():
print "Welcome to my circumference finder!"
intro()
def main():
r=input("What is the radius of the circle? ")
c=r*r*3.14
print "The circumference is", c, "units"
again=raw_input("Do you want to do another calculation? (y or n) ")
if again=='y':
print main()
elif again=='Y':
print main()
else:
print "Good bye"
main()
circle()
When I run the programs seperately, they run fine. When I run the last one and choose the program to run, it says that multiply or circle is not defined. How do I define it without running it before choose()?