The response has been limited to 50k tokens of the smallest files in the repo. You can remove this limitation by removing the max tokens filter.
├── .gitattributes
├── .gitignore
├── README.md
├── generator.py
├── my_first_calculator.py
├── my_first_calculator_0_to_1000.rar
└── setup.py


/.gitattributes:
--------------------------------------------------------------------------------
 1 | # Auto detect text files and perform LF normalization
 2 | * text=auto
 3 | 
 4 | # Custom for Visual Studio
 5 | *.cs     diff=csharp
 6 | 
 7 | # Standard to msysgit
 8 | *.doc	 diff=astextplain
 9 | *.DOC	 diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot  diff=astextplain
13 | *.DOT  diff=astextplain
14 | *.pdf  diff=astextplain
15 | *.PDF	 diff=astextplain
16 | *.rtf	 diff=astextplain
17 | *.RTF	 diff=astextplain
18 | 


--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
 1 | # Windows image file caches
 2 | Thumbs.db
 3 | ehthumbs.db
 4 | 
 5 | # Folder config file
 6 | Desktop.ini
 7 | 
 8 | # Recycle Bin used on file shares
 9 | $RECYCLE.BIN/
10 | 
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 | 
17 | # Windows shortcuts
18 | *.lnk
19 | 
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 | 
24 | # OSX
25 | # =========================
26 | 
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 | 
31 | # Thumbnails
32 | ._*
33 | 
34 | # Files that might appear in the root of a volume
35 | .DocumentRevisions-V100
36 | .fseventsd
37 | .Spotlight-V100
38 | .TemporaryItems
39 | .Trashes
40 | .VolumeIcon.icns
41 | 
42 | # Directories potentially created on remote AFP share
43 | .AppleDB
44 | .AppleDesktop
45 | Network Trash Folder
46 | Temporary Items
47 | .apdisk
48 | 


--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
 1 | # my_first_calculator.py
 2 | I initially saw [Al Sweigart](https://github.com/asweigart)'s [my_first_tic_tac_toe](https://github.com/asweigart/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...
 3 | 
 4 |     sqrt(9500/4) = 48.7339...
 5 |     sqrt(9500/4) ≈ 50 
 6 | 
 7 | 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.
 8 | 
 9 | The generator will not work in Python 2 however it can probably be patched to work by doing `from __future__ import division`
10 | 
11 | ![The image](https://i.imgur.com/ZMvUovj.png)
12 | 


--------------------------------------------------------------------------------
/generator.py:
--------------------------------------------------------------------------------
 1 | from decimal import Decimal as d
 2 | import decimal
 3 | # Generator used to create my_first_calculator
 4 | 
 5 | # Open a file that we can write to
 6 | python_file = open('my_first_calculator.py', 'w')
 7 | # The minimum and maximum numbers we can use
 8 | min_num = 0
 9 | max_num = 50
10 | nums = range(min_num, max_num+1)
11 | signs = ['+', '-', '/', '*']
12 | num_of_ifs = len(signs)*(max_num-min_num+1)**2
13 | 
14 | print("""# my_first_calculator.py by AceLewis
15 | # TODO: Make it work for all floating point numbers too
16 | 
17 | if 3/2 == 1:  # Because Python 2 does not know maths
18 |     input = raw_input  # Python 2 compatibility
19 | 
20 | print('Welcome to this calculator!')
21 | print('It can add, subtract, multiply and divide whole numbers from {} to {}')
22 | num1 = int(input('Please choose your first number: '))
23 | sign = input('What do you want to do? +, -, /, or *: ')
24 | num2 = int(input('Please choose your second number: '))
25 | """.format(min_num, max_num), file=python_file)
26 | 
27 | # For all the numbers and all the
28 | for sign in signs:
29 |     for num1 in nums:
30 |         for num2 in nums:
31 |             equation = "d({}){}d({})".format(num1, sign, num2)
32 |             try:
33 |                 equals = eval(equation)
34 |             except ZeroDivisionError:
35 |                 equals = 'Inf'
36 |             except decimal.InvalidOperation as error:
37 |                 if error == decimal.DivisionByZero:
38 |                     equals = 'Inf'
39 |                 else:
40 |                     equals = 'Undefined'
41 |             # No elif's used to be true to the story and also because
42 |             # Python will throw a recursion error when too many are used
43 |             print("if num1 == {} and sign == '{}' and num2 == {}:".format(num1, sign, num2), file=python_file)
44 |             print('    print("{}{}{} = {}")'.format(num1, sign, num2, equals), file=python_file)
45 | 
46 | print('', file=python_file)
47 | print('print("Thanks for using this calculator, goodbye :)")', file=python_file)
48 | 
49 | # Close the file we have written to
50 | python_file.close()
51 | 


--------------------------------------------------------------------------------
/my_first_calculator_0_to_1000.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AceLewis/my_first_calculator.py/a7aabeaf4973e1c2e5a449ce8bd7e7ee5e091c71/my_first_calculator_0_to_1000.rar


--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
 1 | import os
 2 | from setuptools import setup
 3 | 
 4 | 
 5 | def read(fname):
 6 |     return open(os.path.join(os.path.dirname(__file__), fname)).read()
 7 | 
 8 | 
 9 | setup(
10 |     name="my_first_calculator",
11 |     version="0.1",
12 |     author="Alexander Lewis",
13 |     author_email="info@acelewis.com",
14 |     description="This is my first calculator",
15 |     url="https://github.com/AceLewis/my_first_calculator.py",
16 |     packages=[],
17 |     py_modules=['my_first_calculator'],
18 |     long_description=read('README.md'),
19 | )
20 | 


--------------------------------------------------------------------------------