i'm pretty new to using python...i'm still in the 1st basics...
nyway i've tried to work this up...
but it didn't work :s...
it shows that there's something wrong with the "def" of the add and sub and div and mul formulas...here is the program...
tell me what i did wrong please!!!

print"Simple Calculator"
def menu():
	print"-------------------------------------------------"
	print"the option menu"
	print"1)add"
	print"2)substract"
	print"3)multiply"
	print"4)divide"
	print"5)exit"
	print"-------------------------------------------------"
	return input("please choose the number of the task u want =)"


def add(a,b):
	print"u have chosen 2 add two numbers"
	print a,"+",b,"=",a+b

def sub(a,b):
	print"u have chosen 2 substract two numbers"
	print a,"-",b,"=",a-b

def mul(a,b):
	print"u have chosen 2 multiply two numbers"
	print a,"x",b,"=",a*b

def div(a,b)
	print"u have decided 2 divde two numbers"
	print a,"/",b,"=",a/b

loop=1
choice=0
while loop==1:
	choice=menu()
	if choice==1:
		print add(input("1st number u wanna add"),input("2nd one")
	elif choice==2:
		print sub(input("1st number u wanna substract"),input("2nd one")
	elif choice==3
		print mul(input("1st number u wanna multiply"),input("2nd one")
	elif choice==4
		print mul(input("1st number u wanna divide"),input("2nd one")
	elif choice==5
		loop=0
	else:
		print"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		print"type in the correct number...Between 0 and 6!"
print"thank u 4 using this calculator XD"
print"come again soon =)"

Recommended Answers

All 2 Replies

Here, I fixed it up for you...It errored up because you had some braces and colons ( : )missing.

print"Simple Calculator"
def menu():
    print"-------------------------------------------------"
    print"the option menu"
    print"1)add"
    print"2)substract"
    print"3)multiply"
    print"4)divide"
    print"5)exit"
    print"-------------------------------------------------"
    return input("please choose the number of the task u want =)")


def add(a,b):
    print"u have chosen 2 add two numbers"
    print a,"+",b,"=",a+b

def sub(a,b):
    print"u have chosen 2 substract two numbers"
    print a,"-",b,"=",a-b

def mul(a,b):
    print"u have chosen 2 multiply two numbers"
    print a,"x",b,"=",a*b

def div(a,b):
    print"u have decided 2 divde two numbers"
    print a,"/",b,"=",a/b

loop=1
choice=0
while loop==1:
    choice=menu()
    if choice==1:
        print add(input("1st number u wanna add"),input("2nd one"))
    elif choice==2:
        print sub(input("1st number u wanna substract"),input("2nd one"))
    elif choice==3:
        print mul(input("1st number u wanna multiply"),input("2nd one"))
    elif choice==4:
        print mul(input("1st number u wanna divide"),input("2nd one"))
    elif choice==5:
        loop=0
    else:
        print"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
        print"type in the correct number...Between 0 and 6!"
print"thank u 4 using this calculator XD"
print"come again soon =)"

ok man...i found some mistakes too =P!!!
we have defined the division by mul XD!!!so i found out about it when i was testing it XD!!!
i just thought i should post it anyway...
and i added some few stuff in the division section...
thanks a lot for your help...i can see how stupid i am XD!!!

print"Simple Calculator"
def menu():
	print"-------------------------------------------------"
	print"the option menu"
	print"1)add"
	print"2)substract"
	print"3)multiply"
	print"4)divide"
	print"5)exit"
	print"-------------------------------------------------"
	return input("please choose the number of the task u want =) ")


def add(a,b):
	print"u have chosen 2 add two numbers"
	print a,"+",b,"=",a+b

def sub(a,b):
	print"u have chosen 2 substract two numbers"
	print a,"-",b,"=",a-b

def mul(a,b):
	print"u have chosen 2 multiply two numbers"
	print a,"x",b,"=",a*b

def div(a,b):
	print"u have decided 2 divde two numbers"
	print a,"/",b,"=",a/b
	print"the rest of the division of",a,"by",b,"is",a%b

loop=1
choice=0
while loop==1:
	choice=menu()
	if choice==1:
		print add(input("1st number u wanna add :"),input("2nd one :"))
	elif choice==2:
		print sub(input("1st number u wanna substract :"),input("2nd one :"))
	elif choice==3:
		print mul(input("1st number u wanna multiply :"),input("2nd one :"))
	elif choice==4:
		print div(input("1st number u wanna divide :"),input("2nd one :"))
	elif choice==5:
		loop=0
	else:
		print"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		print"type in the correct number...Between 0 and 6!"
print"thank u 4 using this calculator XD"
print"come again soon =)"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.