r/learnpython • u/mexicanlefty • Jul 09 '20
I made a calculator in Python!
Hello everyone!
I just wanted to share this project i made, its not my first programming project or python project whatsoever, but it is indeed the first one i didnt depended much on google or a video tutorial so that for me its a great advance.
The project is also my first on a github repository!
https://github.com/mexicanlefty/Python-Calculator
Please take a look and test it, in case you can provide any feedback it would be even better, it doesnt matter if you guys want to be very critical, i dont mind i want to keep practicing and i already have my next project in mind.
392
Upvotes
8
u/njape Jul 09 '20
Overall I think it looks good, nice work!
Small comment is that I would change the mode numbers to constants or similar for better readability.
As already noted I don't like global variables, it is a sin. For future projects, and maybe also as an addition to this project, I would urge you to add some unit tests to the code. While doing this you will notice one of the reasons global variables should be avoided. It will also help you to improve how you go about designing your program so that it is modular and testable. Don't care about 100%test coverage in the tests, focus on what functionality is important, special cases and edge cases and you should find a good middle ground.
If you find it hard to isolate a function for unit testing, without major mocking, you most likely have some problem with the design.
Keep up the good work!