Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
[PY] Calculator 2
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
.
Reply to thread
Message
<blockquote data-quote="Sway" data-source="post: 242720" data-attributes="member: 1889"><p>The last thing DevBest needs is another calculator script. No one uses these as an every day calculator (or at least I hope not) but I figured that it does help some of you who are trying to learn how to create scripts like these.</p><p></p><p>Three months ago I released a calculator which was horrible. I looked back at it and found ways that I could improve it...</p><p></p><p><strong>Old version:</strong></p><p><strong><a href="http://pastebin.com/60vUy9XW" target="_blank">http://pastebin.com/60vUy9XW</a></strong></p><p></p><p><strong>New version:</strong></p><p><strong><a href="http://pastie.org/8449037" target="_blank">http://pastie.org/8449037</a></strong></p><p></p><p>Putting the two scripts side by side, you could definitely see the difference. If anyone does use this to learn or base another script off of, use the newer version. I will be constantly updating it with newer features. It currently has the basic four functions (addition, subtraction, multiplication, division) and it can also calculate the factorial and square root of a number.</p><p></p><p><strong>Snippet:</strong></p><p>[CODE]</p><p> operation = input(">").lower()</p><p> operation_choices = ['a','s','m','d','factorial','sqrt']</p><p></p><p> if operation in operation_choices[:4]:</p><p> number1 = input("Number 1: ")</p><p> number2 = input("Number 2: ")</p><p> if operation in operation_choices[0]:</p><p> addition(number1,number2)</p><p> exit_calculator()</p><p> elif operation in operation_choices[1]:</p><p> subtraction(number1,number2)</p><p> exit_calculator()</p><p> elif operation in operation_choices[2]:</p><p> multiplication(number1,number2)</p><p> exit_calculator()</p><p> elif operation in operation_choices[3]:</p><p> division(number1,number2)</p><p> exit_calculator()</p><p> else:</p><p> print("Restart the program until I figure out how to loop this.")[/CODE]</p><p></p><p>Thanks.</p></blockquote><p></p>
[QUOTE="Sway, post: 242720, member: 1889"] The last thing DevBest needs is another calculator script. No one uses these as an every day calculator (or at least I hope not) but I figured that it does help some of you who are trying to learn how to create scripts like these. Three months ago I released a calculator which was horrible. I looked back at it and found ways that I could improve it... [B]Old version: [URL]http://pastebin.com/60vUy9XW[/URL][/B] [B]New version: [URL]http://pastie.org/8449037[/URL][/B] Putting the two scripts side by side, you could definitely see the difference. If anyone does use this to learn or base another script off of, use the newer version. I will be constantly updating it with newer features. It currently has the basic four functions (addition, subtraction, multiplication, division) and it can also calculate the factorial and square root of a number. [B]Snippet:[/B] [CODE] operation = input(">").lower() operation_choices = ['a','s','m','d','factorial','sqrt'] if operation in operation_choices[:4]: number1 = input("Number 1: ") number2 = input("Number 2: ") if operation in operation_choices[0]: addition(number1,number2) exit_calculator() elif operation in operation_choices[1]: subtraction(number1,number2) exit_calculator() elif operation in operation_choices[2]: multiplication(number1,number2) exit_calculator() elif operation in operation_choices[3]: division(number1,number2) exit_calculator() else: print("Restart the program until I figure out how to loop this.")[/CODE] [B][/B] Thanks. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
[PY] Calculator 2
Top