noob who needs help(simple)

Thread Solved

Join Date: Jul 2008
Posts: 6
Reputation: deviantrunner is an unknown quantity at this point 
Solved Threads: 0
deviantrunner deviantrunner is offline Offline
Newbie Poster

noob who needs help(simple)

 
0
  #1
Sep 13th, 2008
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!!!


  1. print"Simple Calculator"
  2. def menu():
  3. print"-------------------------------------------------"
  4. print"the option menu"
  5. print"1)add"
  6. print"2)substract"
  7. print"3)multiply"
  8. print"4)divide"
  9. print"5)exit"
  10. print"-------------------------------------------------"
  11. return input("please choose the number of the task u want =)"
  12.  
  13.  
  14. def add(a,b):
  15. print"u have chosen 2 add two numbers"
  16. print a,"+",b,"=",a+b
  17.  
  18. def sub(a,b):
  19. print"u have chosen 2 substract two numbers"
  20. print a,"-",b,"=",a-b
  21.  
  22. def mul(a,b):
  23. print"u have chosen 2 multiply two numbers"
  24. print a,"x",b,"=",a*b
  25.  
  26. def div(a,b)
  27. print"u have decided 2 divde two numbers"
  28. print a,"/",b,"=",a/b
  29.  
  30. loop=1
  31. choice=0
  32. while loop==1:
  33. choice=menu()
  34. if choice==1:
  35. print add(input("1st number u wanna add"),input("2nd one")
  36. elif choice==2:
  37. print sub(input("1st number u wanna substract"),input("2nd one")
  38. elif choice==3
  39. print mul(input("1st number u wanna multiply"),input("2nd one")
  40. elif choice==4
  41. print mul(input("1st number u wanna divide"),input("2nd one")
  42. elif choice==5
  43. loop=0
  44. else:
  45. print"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
  46. print"type in the correct number...Between 0 and 6!"
  47. print"thank u 4 using this calculator XD"
  48. print"come again soon =)"
Last edited by deviantrunner; Sep 13th, 2008 at 5:29 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 19
Reputation: OutOfReach is an unknown quantity at this point 
Solved Threads: 2
OutOfReach OutOfReach is offline Offline
Newbie Poster

Re: noob who needs help(simple)

 
0
  #2
Sep 13th, 2008
Here, I fixed it up for you...It errored up because you had some braces and colons ( : )missing.

  1. print"Simple Calculator"
  2. def menu():
  3. print"-------------------------------------------------"
  4. print"the option menu"
  5. print"1)add"
  6. print"2)substract"
  7. print"3)multiply"
  8. print"4)divide"
  9. print"5)exit"
  10. print"-------------------------------------------------"
  11. return input("please choose the number of the task u want =)")
  12.  
  13.  
  14. def add(a,b):
  15. print"u have chosen 2 add two numbers"
  16. print a,"+",b,"=",a+b
  17.  
  18. def sub(a,b):
  19. print"u have chosen 2 substract two numbers"
  20. print a,"-",b,"=",a-b
  21.  
  22. def mul(a,b):
  23. print"u have chosen 2 multiply two numbers"
  24. print a,"x",b,"=",a*b
  25.  
  26. def div(a,b):
  27. print"u have decided 2 divde two numbers"
  28. print a,"/",b,"=",a/b
  29.  
  30. loop=1
  31. choice=0
  32. while loop==1:
  33. choice=menu()
  34. if choice==1:
  35. print add(input("1st number u wanna add"),input("2nd one"))
  36. elif choice==2:
  37. print sub(input("1st number u wanna substract"),input("2nd one"))
  38. elif choice==3:
  39. print mul(input("1st number u wanna multiply"),input("2nd one"))
  40. elif choice==4:
  41. print mul(input("1st number u wanna divide"),input("2nd one"))
  42. elif choice==5:
  43. loop=0
  44. else:
  45. print"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
  46. print"type in the correct number...Between 0 and 6!"
  47. print"thank u 4 using this calculator XD"
  48. print"come again soon =)"
Last edited by OutOfReach; Sep 13th, 2008 at 7:38 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 6
Reputation: deviantrunner is an unknown quantity at this point 
Solved Threads: 0
deviantrunner deviantrunner is offline Offline
Newbie Poster

Re: noob who needs help(simple)

 
0
  #3
Sep 13th, 2008
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!!!

  1. print"Simple Calculator"
  2. def menu():
  3. print"-------------------------------------------------"
  4. print"the option menu"
  5. print"1)add"
  6. print"2)substract"
  7. print"3)multiply"
  8. print"4)divide"
  9. print"5)exit"
  10. print"-------------------------------------------------"
  11. return input("please choose the number of the task u want =) ")
  12.  
  13.  
  14. def add(a,b):
  15. print"u have chosen 2 add two numbers"
  16. print a,"+",b,"=",a+b
  17.  
  18. def sub(a,b):
  19. print"u have chosen 2 substract two numbers"
  20. print a,"-",b,"=",a-b
  21.  
  22. def mul(a,b):
  23. print"u have chosen 2 multiply two numbers"
  24. print a,"x",b,"=",a*b
  25.  
  26. def div(a,b):
  27. print"u have decided 2 divde two numbers"
  28. print a,"/",b,"=",a/b
  29. print"the rest of the division of",a,"by",b,"is",a%b
  30.  
  31. loop=1
  32. choice=0
  33. while loop==1:
  34. choice=menu()
  35. if choice==1:
  36. print add(input("1st number u wanna add :"),input("2nd one :"))
  37. elif choice==2:
  38. print sub(input("1st number u wanna substract :"),input("2nd one :"))
  39. elif choice==3:
  40. print mul(input("1st number u wanna multiply :"),input("2nd one :"))
  41. elif choice==4:
  42. print div(input("1st number u wanna divide :"),input("2nd one :"))
  43. elif choice==5:
  44. loop=0
  45. else:
  46. print"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
  47. print"type in the correct number...Between 0 and 6!"
  48. print"thank u 4 using this calculator XD"
  49. print"come again soon =)"
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC