Git Product home page Git Product logo

my_first_calculator.py's Introduction

my_first_calculator.py

I initially saw Al Sweigart's my_first_tic_tac_toe and was amused. I then saw the image shown below posted on Reddit. Assuming that the image was not made up for some fake internet points and also assuming that their friend only used addition, subtraction, multiplication and division then the number of numbers that they would have if statements for would be...

sqrt(9500/4) = 48.7339...
sqrt(9500/4) โ‰ˆ 50 

So to be true to the "real" story I have only gone from 0-50 however higher numbers can easily be generated too however my Python crashes with larger numbers. I generated one that was 0-1000 and it took up 317 MB of space on my hard drive but was only 20MB after I compressed it to a .rar so I have also attached it.

The generator will not work in Python 2 however it can probably be patched to work by doing from __future__ import division

The image

my_first_calculator.py's People

Contributors

acelewis avatar clearsense avatar juanpotato avatar svilgelm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

my_first_calculator.py's Issues

Support for 99

Please, add support for 99, i dont know much its 99+1 :(

No Code of Conduct

I propose to create Code of Conduct for this project.
There is need for lot of developers here until we
reach short int

Error help

worst thing i have ever seen in my life. Please fix it.

Extend to 2 000 000 000 please

Thank you for very useful calculator. Could you extend range of this calculator? -2147000000000...2147000000000 looks like good.
Thank you!

Impressive

When is the next version going to be released?

Can this be ported?

I'd love to see this in some other languages, as it's highly useful. COBOL comes to mind, or maybe R

Missing tests

You are missing unit tests. You should cover the code with tests.

I mean for my_first_calculator.py itself of course.

Generator for the Generator | Calc 51

Due to some earlier feature requests, we could also write a generator for the generator to support numbers like 51, just by generating the generator with dynamic min an max values.

We could generate every new feature request a user could have ๐Ÿ˜

This code need optimization

You exit from positive IF and continue check others IF's. This is unnecessary.

You need to use RETURN in every IF statement. Will be huge performance jump.

5/11 calculated wrong

if num1 == 5 and sign == '/' and num2 == 11:
print("5/11 = 0.45454545454545453")

5/11 shouldn't have 3 as its last digit.
Rather end with a 5. Also precision seems to vary. ;)

Perfect for learning

This is a perfect example of writing clean, easy to read, and refactored code.

When people ask me "How do I learn how to code", I'll be sending them here!

add big int

Really nice calculator! We try use it in entreprise project but we need bigInt. Please add it.

Feature request : perform runtime profiling and branch reordering

As discussed here, and other seminal computer science works : https://dl.acm.org/citation.cfm?id=586091

Performing branch reordering would re-arrange the control statements such that the most likely calculator results are tested first, saving unnecessary tests. To do this properly, one would need to profile usage of this software among many users to obtain a statistically represented pattern of common mathematical operations.

Alternatively, in the absence of runtime profiling, one could make educated guesses that certain patterns are more likely. It can be argued that more users are aware of positive numbers than negative numbers, so those control flow tests should be hoisted lower in the branching logic.

Another possibility is we implement a JIT that does runtime-level branch reordering based on observed test frequency. Such a contribution would be welcome at @numba.

Code Needs to Be a Bit Shorter

Your code is great but could you make it a bit shorter. You can add methods with parameters 'sign', 'num1' and 'num2'

def add(num1 = None, num2 = None):
    answer = num1 + num2
    print(answer) # You can also do 'return answer'

Fiverr , Freelancer , Upwork - Can you code ? Yes, can , 100% to your satisfaction.

Fiverr , Freelancer - Can you code ? Yes, can , 100% to your satisfaction. We are a team of IT professionals , good portfolio , promise you will meet your standard.
Please pay first, don't worry, we experienced.

  • Can you do this structure/per project description?
    Yes we can, no problem. Very fast finish.

This really reminds me of hiring from Fiverr, Freelancer, Upwork when it comes to users with low/mid reviews. Don't be surprised to find such code standard from top "reviewers".

74408277_1541109122695835_6958515522589687808_o

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.