| | |
noob who needs help(simple)
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 |
address aliased anydbm app bash beginner bits calling casino changecolor cipher clear conversion coordinates corners count cturtle curves definedlines development dictionary digital dynamic events examples excel external feet file float format function gui handling hints homework iframe images import input java keycontrol line linux list lists loan loop matching mouse multiple number numbers output parsing path port prime programming projects py py2exe pygame pymailer python random rational raw_input recursion recursive scrolledtext searchingfile shebang signal singleton split string strings tails terminal text threading time tlapse tooltip tuple tutorial type ubuntu unicode url urllib urllib2 valueerror variable web-scrape whileloop word wxpython xlwt





