How To Make Basic Python Calculator Program – 2016

We all know what a calculator is so we are going to make a basic calculator using python obvious. This Python calculator will contain trig ratios, addition, exponent which is POW-POWER , SQUAREROOT, SUBTRACTION, DIVISION and MULTIPLICATION.

Go ahead of python open your python’s idle then new window, now let’s start coding:

Basic Python Calculator

 

We have to first make our own functions by the attribute def. As we are going to use the trig ratios, exponent pow and squareroot.  We have to import a module, that module is math import math

Now let’s define our functions:Basic Python Calculator

After defining our functions we have to take input from user, but before we take input from user we have to alert the user of the options available to use as below:

Basic Python Calculator

We then make a variable as above ,I named mine choice you can name yours anything you want. The variable should be take input from user which will be stored for future use.

Now after doing that, as you saw above our calculator will only hold two variable X and Y.

We have to make the x and y variables which will allow the user to enter input any number they want which will be in a FLOAT in order to obtain numbers with decimals:

X = num1

Y = num2

Basic Python Calculator

We have to include an if else and elif statement to make the code be able to execute what the user has bid for:

Basic Python Calculator

WELL DONE YOUR CALCULATOR IS COMPLETE SAVE IT AS BASICCALCULATOR.PY

Don’t worry about the last statement you can add it if you want to execute your program at the command line.

END!!!!!!!!!!!!!!!!

Download Source Code Of Basic Python Calculator : – Click here

 

5 Comments

  1. RaZoR April 4, 2016
    • mualusidiego April 5, 2016
  2. brainst April 11, 2016
    • mualusidiego April 11, 2016
    • Kamal Thakur April 11, 2016