Idea and Need:
Every one of us uses default calculator on PC (yeah, it's a great one...), but as a programmer, we are the one who spends most of the time on CMD or terminal (for MAC once). So why not create a simple calculator which can be used on CMD and yes, it feels so good when you use your own programs to complete daily stuff.So let's see what steps you should follow...
Steps:
- We have to create a menu which has the option to select which operation to perform.
- You can add as many operations as you want, but I am taking following basic one:
- Addition
- Subtraction
- Multiplication
- Division(remember about 0...😎)
- Power
- Square Root
- Natural Log
- Log to base 10
- Factorial
- Show user that what are you doing...for example if it is the addition of 2 and 3, print 2 + 3 = 5 on screen.
- After performing any operation ask the user if he/she again want to use the calculator. If yes, run calculator again otherwise exit the program.
- Take help of google, stack overflow wherever needed instead of looking my code.
- It is a very easy application, so try to complete it in a minimum time as possible.
- Create functions wherever possible, so that your code will look neat and clean.
Modules required:
- math
What you will learn:
- Basic loops and menu driven program
- Will get familiar with "math" module
- Benefit of using functions in large program
Code:
GitHub Link:
I have written very simple and well informative code. There are many places where you can reduce the size of code and optimise it.
I encourage you to fork and star the repository on GitHub and make improvements. I will surely consider to add them.
What Next:
You can add many other functions to the program:
- Add GUI (using Tkinter or other modules)
- Add more operations in calculator
- You can also add binary, decimal, hexadecimal and octal converter
That's all for this project. Comment if any bugs or errors are present in the program. Comment any new ideas and yes, share this post so that others can learn something new
Check out other simple projects:
Python Project - 1 (Password Locker)
- Add GUI (using Tkinter or other modules)
- Add more operations in calculator
- You can also add binary, decimal, hexadecimal and octal converter
That's all for this project. Comment if any bugs or errors are present in the program. Comment any new ideas and yes, share this post so that others can learn something new
Check out other simple projects:
Python Project - 1 (Password Locker)
Comments
Post a Comment