my_first_calculator.py
Go to file
clearsense 22fff8911c fix num_of_ifs calculation
num_of_ifs should be calc like this, because numeration start from 0
2016-05-14 17:00:29 +03:00
.gitattributes :neckbeard: Added .gitattributes & .gitignore files 2016-05-05 22:42:39 +01:00
.gitignore :neckbeard: Added .gitattributes & .gitignore files 2016-05-05 22:42:39 +01:00
README.md Next time spell check before pushing 2016-05-06 18:52:56 +01:00
generator.py fix num_of_ifs calculation 2016-05-14 17:00:29 +03:00
my_first_calculator.py Fixed 0/0 being Inf not undefined 2016-05-10 16:23:54 +01:00
my_first_calculator_0_to_1000.rar First commit 2016-05-06 18:48:18 +01:00
setup.py Add setup.py 2016-05-06 22:34:04 -07:00

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 .rat so I have also attached it.

The generator will not work in Python 2 it can easily be patched to work by putting a ".0" on the end of the eval and then cutting off the last two when printing the equation but I decided to not do what because it would add a ".0" to the end of additions, subtractions and multiplications (or you could use an if statement but I decided to miss that out).

The image