| | |
noob who needs help(simple)
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jul 2008
Posts: 6
Reputation:
Solved Threads: 0
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!!!
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!!!
Python Syntax (Toggle Plain Text)
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 =)"
Last edited by deviantrunner; Sep 13th, 2008 at 5:29 pm.
•
•
Join Date: Aug 2008
Posts: 19
Reputation:
Solved Threads: 2
Here, I fixed it up for you...It errored up because you had some braces and colons ( : )missing.
Python Syntax (Toggle Plain Text)
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 =)"
Last edited by OutOfReach; Sep 13th, 2008 at 7:38 pm.
•
•
Join Date: Jul 2008
Posts: 6
Reputation:
Solved Threads: 0
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!!!
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!!!
Python Syntax (Toggle Plain Text)
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 =)"
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- NOOB flashback (C++)
- Noob Help needed for Time problem (C++)
- Complete noob needs lots of help (Networking Hardware Configuration)
- Semi-noob help (PHP)
- Need some simple help! (C++)
- You'r friendly, CDN, complete noob say Hi! (Community Introductions)
- Redhat 9.0 Server Recommendations (Linux Servers and Apache)
Other Threads in the Python Forum
- Previous Thread: replace in time.asctime?
- Next Thread: VolumeRendering.py
| Thread Tools | Search this Thread |
Tag cloud for Python
abrupt ansi anti apache approximation array backend basic beginner book builtin calculator chmod code converter countpasswordentry curved dan08 dictionaries dictionary dynamic examples excel file filename float format ftp function gui heads homework import inches input java launcher library line lines linux list lists loop mouse mysql mysqlquery number numbers numeric output parsing path phonebook plugin port prime programming progressbar projects py2exe pygame pyqt pysimplewizard python random recursion recursive redirect refresh scrolledtext software ssh stamp statictext statistics string strings table terminal text textarea thread threading time tkinter tlapse trick tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable windows wordgame wxpython





