Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
ZTE MF283U 4G Unlocked Router (Used)
ayanthamaxi
Updated:
Yesterday at 8:26 PM
ලංකාවේ හොඳම උපකාරක පන්ති සහ ගුරුවරුන් එකම තැනකින් - TopTuition.lk
dulithapathum
Updated:
Saturday at 8:07 AM
Colombo
RidhMathraa ’26 🎶✨
Tmadhusanka
Updated:
Wednesday at 11:58 PM
Ad icon
Colombo
PXN V10 Pro Direct Drive Racing Wheel (Under Warranty)
Abdur Rahman
Updated:
Wednesday at 10:23 PM
Ad icon
USDT ණය සේවාව - USDT Loan Service
පුරවැසියා
Updated:
Wednesday at 4:54 PM
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
Python Code help For Implement a list
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="hancok" data-source="post: 27469113" data-attributes="member: 119642"><p>stock apu code kalla go kiyala function ekak asse danna one na. mama nikan damme passe recall karanna ona unoth kiyala</p><p></p><p>[CODE=python]def select_op(choice):</p><p> lst = ["","+","-","*","/","^","%"]</p><p> if choice == "#":</p><p> return 7</p><p> elif choice in lst:</p><p> return lst.index(choice)</p><p></p><p> # take input from the user</p><p>def inputfn():</p><p> choice = input("Enter choice(+,-,*,/,^,%,#,$): ")</p><p> </p><p> print(choice)</p><p> choicenum = select_op(choice)</p><p> </p><p> if(choicenum == 7):</p><p> #program ends here</p><p> print("Done. Terminating")</p><p> exit()</p><p> elif "$" in choice:</p><p> inputfn()</p><p> elif choicenum in range(1,7):</p><p> number1 = input("Enter first number: ")</p><p> print(number1)</p><p> if "$" in number1:</p><p> go()</p><p> if "#" in number1:</p><p> print("Done. Terminating")</p><p> exit()</p><p> number2 = input("Enter second number: ")</p><p> print(number2)</p><p> if "$" in number2:</p><p> go()</p><p> if "#" in number2:</p><p> print("Done. Terminating")</p><p> exit()</p><p> </p><p> if choicenum == 1:</p><p> print(float(number1),"+",float(number2),"=",float(number1) + float(number2))</p><p> </p><p> elif choicenum == 2:</p><p> print(float(number1),"+",float(number2),"=",float(number1) - float(number2))</p><p> </p><p> elif choicenum == 3:</p><p> print(float(number1),"+",float(number2),"=",float(number1) * float(number2))</p><p> </p><p> elif choicenum == 4:</p><p> if number2 == "0":</p><p> print("float division by zero")</p><p> print(float(number1),"/",float(number2),"=","None")</p><p> else:</p><p> print(float(number1),"+",float(number2),"=",float(number1) / float(number2))</p><p> </p><p> elif choicenum == 5:</p><p> print(float(number1),"+",float(number2),"=",float(number1) ** float(number2))</p><p> </p><p> elif choicenum == 6:</p><p> print(float(number1),"+",float(number2),"=",float(number1) % float(number2))</p><p> </p><p> </p><p>def go():</p><p> while True:</p><p> print("Select operation.")</p><p> print("1.Add : + ")</p><p> print("2.Subtract : - ")</p><p> print("3.Multiply : * ")</p><p> print("4.Divide : / ")</p><p> print("5.Power : ^ ")</p><p> print("6.Remainder: % ")</p><p> print("7.Terminate: # ")</p><p> print("8.Reset : $ ")</p><p> inputfn()</p><p></p><p>go()</p><p> </p><p> </p><p>[/CODE]</p><p></p><p></p><p>ah na na go() kiyana eka define karanna one. madin recall wela neh</p></blockquote><p></p>
[QUOTE="hancok, post: 27469113, member: 119642"] stock apu code kalla go kiyala function ekak asse danna one na. mama nikan damme passe recall karanna ona unoth kiyala [CODE=python]def select_op(choice): lst = ["","+","-","*","/","^","%"] if choice == "#": return 7 elif choice in lst: return lst.index(choice) # take input from the user def inputfn(): choice = input("Enter choice(+,-,*,/,^,%,#,$): ") print(choice) choicenum = select_op(choice) if(choicenum == 7): #program ends here print("Done. Terminating") exit() elif "$" in choice: inputfn() elif choicenum in range(1,7): number1 = input("Enter first number: ") print(number1) if "$" in number1: go() if "#" in number1: print("Done. Terminating") exit() number2 = input("Enter second number: ") print(number2) if "$" in number2: go() if "#" in number2: print("Done. Terminating") exit() if choicenum == 1: print(float(number1),"+",float(number2),"=",float(number1) + float(number2)) elif choicenum == 2: print(float(number1),"+",float(number2),"=",float(number1) - float(number2)) elif choicenum == 3: print(float(number1),"+",float(number2),"=",float(number1) * float(number2)) elif choicenum == 4: if number2 == "0": print("float division by zero") print(float(number1),"/",float(number2),"=","None") else: print(float(number1),"+",float(number2),"=",float(number1) / float(number2)) elif choicenum == 5: print(float(number1),"+",float(number2),"=",float(number1) ** float(number2)) elif choicenum == 6: print(float(number1),"+",float(number2),"=",float(number1) % float(number2)) def go(): while True: print("Select operation.") print("1.Add : + ") print("2.Subtract : - ") print("3.Multiply : * ") print("4.Divide : / ") print("5.Power : ^ ") print("6.Remainder: % ") print("7.Terminate: # ") print("8.Reset : $ ") inputfn() go() [/CODE] ah na na go() kiyana eka define karanna one. madin recall wela neh [/QUOTE]
Insert quotes…
Verification
Asuwa dahayen wadi kalama keeyada?
Post reply
Top
Bottom