create calculator in python

Solutions on MaxInterview for create calculator in python by the best coders in the world

showing results for - "create calculator in python"
Alina
20 May 2016
1#Store number variables for the two numbers
2
3num1 = input('Enter first number: ')
4num2 = input('Enter second number: ')
5
6#the sum of the two numbers variable
7sum = float(num1) + float(num2)
8sum2 = float(num1) - float(num2)
9sum3 = float(num1) * float(num2)
10sum4 = float(num1) / float(num2)
11
12#what operator to use
13choice = input('Enter an operator, + = addition, - = subtraction, * = multiplication and / = division: ')
14#different sums based on the operators
15if choice == '+':
16  print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
17
18  if choice == '-':
19    print('The sum of {0} and {1} is {2}'.format(num1, num2, sum2))
20
21if choice == '*':
22    print('The sum of {0} and {1} is {2}'.format(num1, num2, sum3))
23
24if choice == '/':
25    print('The sum of {0} and {1} is {2}'.format(num1, num2, sum4))
26 
Kassandra
13 Jan 2017
1from tkinter import *
2import random
3import time
4
5def btnClick(numbers):
6	global operator
7	operator = operator + str(numbers)
8	text_Input.set(operator)
9
10def bcd():
11	global operator
12	operator = ""
13	text_Input.set("")
14
15def bei():
16	global operator
17	sumup = str(eval(operator))
18	text_Input.set(sumup)
19	operator = sumup
20
21
22root = Tk()
23root.title("Calculator")
24root.resizable(False, False)
25
26operator = ""
27text_Input = StringVar()
28
29#AnsShow
30textDisplay = Entry(root, font = ('arial', 20, 'bold'), textvariable = text_Input, bd = 30, insertwidth = 4, bg = "red", justify = 'right')
31textDisplay.grid(columnspan = 4)
32
33#button
34btn7 = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "7", command = lambda:btnClick(7)).grid(row = 1, column = 0)
35
36btn8 = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "8", command = lambda:btnClick(8)).grid(row = 1, column = 1)
37
38btn9 = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "9", command = lambda:btnClick(9)).grid(row = 1, column = 2)
39
40Add = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "+", command = lambda:btnClick("+")).grid(row = 1, column = 3)
41
42#============================================================================================================================#
43btn4 = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "4", command = lambda:btnClick(4)).grid(row = 2, column = 0)
44
45btn5 = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "5", command = lambda:btnClick(5)).grid(row = 2, column = 1)
46
47btn6 = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "6", command = lambda:btnClick(6)).grid(row = 2, column = 2)
48
49Sub = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "-", command = lambda:btnClick("-")).grid(row = 2, column = 3)
50
51#===============================================================================================================================#
52btn1 = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "1", command = lambda:btnClick(1)).grid(row = 3, column = 0)
53
54btn2 = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "2", command = lambda:btnClick(2)).grid(row = 3, column = 1)
55
56btn3 = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "3", command = lambda:btnClick(3)).grid(row = 3, column = 2)
57
58Multiply = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "*", command = lambda:btnClick("*")).grid(row = 3, column = 3)
59
60#==================================================================================================================================#
61btn0 = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "0", command = lambda:btnClick(0)).grid(row = 4, column = 0)
62
63equal = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "=", command = bei).grid(row = 4, column = 1)
64
65divide = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "/", command = lambda:btnClick("/")).grid(row = 4, column = 2)
66
67clear = Button(root, padx = 16, bd = 8, fg = "black", bg = "red", font = ('arial', 20, 'bold'), text = "c", command = bcd).grid(row = 4, column = 3)
68
69root.mainloop()
Henry
25 Feb 2017
1from whiteCalculator import Calculator
2c = Calculator()
3print(c.run("1+8(5^2)"))
4# Output: 201
5print(c.run("9Ans"))
6# Output: 1809
Linda
23 Oct 2017
1num_one = int(input("Enter 1st number: "))
2
3op = input("Enter operator: ")
4
5num_two = int(input("Enter 2nd number: "))
6
7if op == "+":
8    print(num_one + num_two)
9elif op == "-":
10    print(num_one - num_two)
11elif op == "*" or op == "x":
12    print(num_one * num_two)
13elif op == "/":
14    print(num_one / num_two)
15
Leah
20 Jul 2018
1# This will be one of the most advanced results you will find.
2
3# We will be using classes and simple operators like +,-,*,/
4
5class Calculator:
6  def addition(a,b):
7    return a + b
8
9  def subtraction(a,b):
10    if a<b:
11      return b - a
12    else:
13      return a - b
14
15  def multiplication(a,b):
16    return a * b
17
18  def division(a,b):	
19    if a<b:
20      return b / a
21    else:
22      return a / b
23
24# You can do this in terminal.
25<C:/Users/username>python
26>>> from main import Calculator
27>>> result = Calculator.[addition|subtraction|multiplication|division](anyNumber, anyNumber)
28>>> print(result)
Regina
05 Jan 2018
1print("Enter Your Choice 1(Add)/2(Sub)/3(Divide)/4(Multiply)")
2num = int(input())
3if num == 1:
4    print("Enter Number 1 : ")
5    add1  = int(input())
6    print("Enter Number 2 : ")
7    add2 = int(input())
8    sum = add1 + add2
9    print("The Sum Is ", sum)
10elif num == 2:
11    print("Enter Number 1 : ")
12    sub1  = int(input())
13    print("Enter Number 2 : ")
14    sub2 = int(input())
15    difference = sub1 - sub2
16    print("The Difference Is ", difference)
17elif num == 3:
18    print("Enter Number 1 : ")
19    div1  = float(input())
20    print("Enter Number 2 : ")
21    div2 = float(input())
22    division = div1 / div2
23    print("The Division Is ", division)
24elif num == 4:
25    print("Enter Number 1 : ")
26    mul1 = int(input())
27    print("Enter Number 2 : ")
28    mul2 = int(input())
29    multiply = mul1 * mul2
30    print("The Difference Is ", multiply)
31else:
32    print("enter a valid Number")
queries leading to this page
basical calculator pythonpython create calculator with modulepython calculator modulecalculator class pythoncalculator in pythcalc in pythoncalculation in python python py make a calculatorcalculator python code glebber how to make a simple calculator using pythonpythin calc packagecalculaor with pythonwrite a python program to design a simple calculator 28using functions 29 coding on a calculaotr in pythonis calculate a function in pythoncalculator python projectinput calculator pythonsimple caculation pythonsimple calculator in python using functionsbasic calculator pythonhow to make a calculator in python calculator phythonhow to run python calculator code the programe should performe the operation selectedsimple calculator docs pythoncalculator python onlinepython create calculatorcreate a calculator where user have a menu to perform addition 2f subtraction 2f multiplication 2f division 2f display tables using loops in python calculator program in python using functionshow to write calculator pythoncreating a calculator pythonpython code for calculator downloading filehow to create calcultor in pythonpython calcbuilding calculator pythoncalculatrice with pythonpython simulate a four operations calculatorpython as a calculator codepython make a simple calculator simple compute pythonpython calculator code pdfcalculators that use pythonpython code calculatorpython simple calculator expressionpython create function that calculatesmake calculator with pythonptython code of calculatorcreate a calculator function pythonpython script calculatorhow to make a calculator in pythonpython calculatrbasic calculator which can perform 2 or 3 number calculations pythonsimple calculator python with functionshow to create calculator in pythonhow make a calculator in pythonsimple python calculatorcalculate in python and display in chow to create a calcualtor in python3calculator in python functionpython code for calcculatorsimple calculator project in pythonhow to code calculator in pythoncalculator project in pythoncode for building calculator in pythonhow to make a simple python calculatorhow to create a calculator in pythoncode to make a calculator in pythonpython program to make a simple calculator 28using functions 29generating a calculator with pythoncreate a calculator from modules in pythonwriting a calculator in pythoncalculator with pythonsimple computation pythonpython code for a working calculatorpython program to build calculatorcalculator coding in pythonmake calculator using pythoncode for python calculatorpython script for calculatorpython create module calculatorpython calculator sample codebasic calculator in pythonhow to have a calculating input in pythonpython program to make a calculatorscript for calculator in pythonbuild a calculator using pythonhow to make calculator in pythonpython easy calcutalorcalculator pyhtoncalculator live python code exampledo a calculator in pythowrite a program to create a simple calculator in python calculator code pythonmake a simple calculator in pythonbasic python calculatormake a caleculatoer in pythoncalculator python scriptpython module calculator programcalculator excersise in pythoncalculator in pythonbpython calculetor lagorithamhow to make a silmple calculaytor in pythonhow to make calculator pytoncan you make a calculator with pythoncan you code a calculator in pythoncalculator code python 3how to make a calculator in python without defined functioncalcaulator in pythonwhat do you need to create a python calculatormake a calculator app in pythoncalculator script pythonconstruct a python program to make a simple calculator calculate x pythonpython program for simple calculator 25 calculator for pythonpython calculator codeshow to make a simple calculator using functions in pythonhow to calculate using pythonpython calucaltor codehow to code a calculator in pythonpython logic calculatorpython build calculatorpython calculator examplehow to make a calculator in python for beginnershow to use python as a calculatorpython calculator codehow to make a simple calculator in pythonbasic calculator python3 solutioncreate calculator in pythonarithmetic calculator pythoncalculator algorithm pythononline python calculatorhow to do a calculator in pythonpython calculator programpython as a calculatorprograming a calculator to pythoncreate a calculator using pythonmake calculator pythobhow to code a python calculatorpython make a calculatorpython input 28 29 to calculatorpython calculator functioncode for making calculator in pythoncomplication pyhton calculatormake a calculator in python30000 line python calculayothow to create calculator app in pythonpython calculator program on pythonpython calculator scriptmake calculator pythonbest way to create calculator programmake a basic calculator in python python calculatirhow to make a calculator pythonhow to add a calculation function in pythoncalculator codes in pythonpython program to simple calculatorcalculator coding pythonhow to do calculator in pythoncode for calculatorbuild calculator with pythonpython calcualtorpython making a calculatorhow to create a web based calculator with pythonpython code for calculatorcalculator making in pythonbest python calculatorhow to build a calculator in pytonhow to make function calculator in pythoncalculator python source codewrite a calculator code in pythoncreate a calculator in pythoncalculatrice pythonpython 2c calorie calculatorpython program to make calculatorpython list calculatorcalculator based project python class 12calculator on pythonhow to make simple calculator in pythoncan you make a calculator using pythoncreate a simple calculator in any language of your choice consider only addition 2c subtraction 2c multiplication and division operations take input from the user as a string as input 2820 2a 2830 2b 10 29 2f 2810 2a 2 29 29 should print out 40 calculator that use python to programcode calculator pythonhow to do a calculator in pybasic calculator codehow to give input into calc exe using pythonpython how to make a calculatorphython calculatorarithmetic calculator in pythonpython calorie calculatorcode calculatrice pythonfunction to calculate python how to create a simple calculator in pythonbuild a calculator in pythonpython cidr calculatorpython calculaor filewrite a calculator in pythonhow to use python on your calculatorhow to make calculation in pythoncode for calculator in python 2 7how to make calculator pythonsimple calculator using pythononelinecalculator pythonstrcutured package for calculator using pythonwap to model a simple calculator using functions for the following operationssimple calculator program in pythonoperations examples for calculator projectsimple calculator in python using swithcerpython calculatorcalculator basic in pythoncalculator in python codecalculator program in python using functionpython simple calculator with functionsmaking a calculator in pythonpython calculator code copy and pastecode for a calculator in pythonpython display calculator python input calculatorcalculator code in python for write a program that performs the tasks of a simple calculator the program should first take an integer as input and then based on that integer perform the task as given below python caculatorcalculator in pythonpython calculataorcode in python for calculatorvlsm calculator pythonhow to write calculations in pythononline calculator using pythonbuild simple calculator using pythonimport calculator in pythonsimple calculator python scripthow to make your own calculator softwarehow to build a calculator in pythonpython calculator anscalculatord you can do with pythonpython calculator onlinecalculatror pythonhow to create python calculatorpython program to design a simple calculator 28using functions 29 kalkulator code pythonwrite a python program for calculatorhow to make an calculator in pythonpython calculator project in jupytercreating a simple calculator in python python interpreter as calculator codehow to make a calculator using pythonhomework 5 3a multiplication calculator pythonpython program to basic calculatorpython simple calculator whith only integercalculator python 5cwww creating calculator by using pythoncreating a calculator in pythonsimple python program for calculatorcreate code of calaculator in pythonhow to make a boolean function in pythoncalculator python 3how to code calculator in python without functionsimple calculator in pythonhow to create a calulator in pythonhow to build a calculator in python calculator in pythonpython calculatorhow to make 22function calculator 22 in pythonmaking a calculator in python using functionshow to make a python calculatorcalculator pyhton projectcalculator pythoncalculator on pyhotnhow to write calculator program in pythoncalculatorbesic calculator in phytoncalculator module pythonhow to add a calculation in pythonpython calculator librarybasic calculator using pythonhow to make basic calculator in pythonwrite a python program to demonstrate basic calculator functionality using the concept of functions in python python module calculatorcalculator in python for beinerscalculator in python projectwrite a program in python to display artimatic calculatorpython basic calculatorpython program to make simple calculatorhow to make a simple calcualator in pythoncomputation code pythonpython projects using calculationscalculator using pythoncalculator code in pythonpython calaculatortaking an operation as input how to calculate pythonsimple calculator in python without functionsimple calculator application pythonpythag calculatorpython calculator projecthow to make a calculator in puthonmake a simple calculator using python mathematical operations calculator define using function in pythonpython calculatiorcalculator in python3simple calculator using function in pythonpython program for calculatorcode for calculator in pythonpython simple calculatorpython program to create a calculatorcoucalator in pythoncool calculators we can create with pythoncalculater app in pythoncalculator python codehow to make calculator with pythoncalculator syntax for pythonpythion calculatorhow to make a calcualtor pythonmake calculator in pythonpython calculator basic codepython calculator file linecalculator pythonhow to make a online calculator in pythoncalculator program pythoncreate a function calculator in pythoncreate calculator pythonhow to make calculator by using pythondef calculator pythonpy calculatormaking calculator in pythonpython arithmic calcilatorcalculator code using pythonpython calculator example with chekcuse in python calculationpython calculator codeingbuilding a calculator in pythonprogram calculatorcalculator in pyhtonpython code for a calculatorcalculator python programsimple calculator code in pythonpython calculator program using main functioncalc function in pythonhow to create a calculator program in pythoncalculator python librarycalculator made with pythondo a calculator in pythonhow to make python calculator which calculates two or 3 valuescode for calculator app in pythonhow to store calculator numbers in pythonhow to code a simple calculator in pythoncalculate in pythonpython program calculatorpackages needed to build calculator pythonpython simple calculator programhow to make a addition calculator in pythonwith what module can i create calculator in pythonpython function calculatorpython code to make a calculatorhow to make a basic calculator in pythoncoding a simple calculator in pythongenerate python function given input and output data online calculatorpython calculatepython calculator display a menu with operation options inputcalculator price in python using functionspython calculas programhow to make a calculator inpymaking a text based calculator in pythonbasic calculator in python using functionssimple calculator command in pythoncalculator using functions in pythonimplement basic calculator pythoncode python calculatorpython as calculatordef function python calculationpython make calculatorbasic calculator with pythonrun calculator pythonsimple basic calculator with pythoncalculator program using functions in pythonsimple calculator with pythonhow to make a calculator python 2calculator that runs pythondoes python have calculatorpython program that creates estimatorsimple calculator operations pythonhow to make a subtraction calculator in pythonmaking a simple calculator in pythonpython how to make calculatorcreate your own calculator function pythonbuilding calculator in pythonbasic py calculatorsimple calculator python codepython calculattorcalcualator with pythoncalculus calculator in pythonpython build calculator stringcalculator program in pythoncalculator questions program in pythoncalculatrice in pythonwriting a calculator on pythoncalculat pythoncalculate lcpd pythonpyhton calculatorpython estimator programpython program for simple calculator input given from command promptpython code for a calculus calculatorhow to make python calculatormake a python calculator for ligningermake console calculator in pythonimplement calculatorsimple calculator python2 09python program to make a simple calculatorhow to write a calculator program in pythonhow to make calculator in pythone xplaineduse built in calculator pythoncreating calculator in pythonbest python calculatorshow to make a coucalator pythonpython console calculatorcalculate function do in pythonwhich type of coding in calculatercode for simple calculator in pythoncreate calculator in python