calculator with python

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

showing results for - "calculator with python"
Niclas
18 Mar 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 
Celina
09 Aug 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()
Samuel
27 Jan 2019
1from whiteCalculator import Calculator
2c = Calculator()
3print(c.run("1+8(5^2)"))
4# Output: 201
5print(c.run("9Ans"))
6# Output: 1809
Hippolyte
11 Jun 2019
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
Lief
01 Jun 2019
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)
Farah
07 Jun 2019
1#Simple python Calculator
2#Enter the first variable
3#then the operator
4#and finally the second variable, then the answer is printed.
5A = int(input("Enter your first number: "))
6operator = input("Which operation would you like to perform? (+, -, /, *, //, **): ");
7B = int(input("Enter your second number: "))
8#Addition
9if operator == "+":
10    ans = A + B
11    print(str(ans))
12#Subraction
13elif operator == "-":
14    ans = A - B
15    print(str(ans))
16#division
17elif operator == "/":
18    ans = A / B
19    print(str(ans))
20#Multiplication
21elif operator == "*":
22    ans = A * B
23    print(str(ans))
24#Integer division
25elif operator == "//":
26    ans = A // B
27    print(str(ans))
28#Exponent
29elif operator == "**":
30    ans = A ** B
31    print(str(ans))
32else:
33    print("wrong operator!")
34  
queries leading to this page
basical calculator pythonpython create calculator with modulepython calculator modulecalculator class pythoncalculator in pythcalc in pythoncalculater codepython py make a calculatorhow to make a simple calculator using pythonpythin calc packagewhat is the code for a calculatorcalculaor with pythonjavascript notes to make a calculatorwrite 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 pythonbasic calculator python calculator phythonhow to make a calculator in pythonhow to run python calculator code the programe should performe the operation selectedsimple calculator docs pythoncalculator python onlinepython calculator procalculator logic in javascriptpython create calculatorcalculator using javascript codecalculator 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 calculatorjs calculator codepython simple calculator expressioncalculator js htmlpython create function that calculatesmake calculator with pythonptython code of calculatorcreate a calculator function pythoncode calculatorpython script calculatorhow to make a calculator in pythoncreate multiple calculator using javascriptpython calculatrbasic calculator which can perform 2 or 3 number calculations pythoncode for a calculatorsimple calculator python with functionshow to create calculator in pythonhow to make a calculator javascripthow make a calculator in pythoncalculator module in pythonsimple python calculatorcalculate in python and display in cwant to code a calculator with different values simple 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 pythonjavascript calculatorpython 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 codehow to have a calculating input in pythonbasic calculator in pythonpython on calculatorpython program to make a calculatorcalculator js codescript for calculator in pythonbuild a calculator using pythonhow to make calculator in pythonjavascript calculator without input fieldpython 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 calculatorscript for calculator with html and javascriptcalculator 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 pythonmake a calculator on python vs codeconstruct 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 build a calculator with javascriptpython calucaltor codepython logic calculatorpython build calculatorpython calculator examplehow to make a calculator in python for beginnershow to use python as a calculatorpython ccalculetorhow to make a simple calculator in pythonpython calculator codebasic calculator python3 solutioncreate calculator in pythonarithmetic calculator pythoncalculator 5dm 2cake a calculator in jsprogramming a calculatorexamples of calculations in 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 pythobcalculator in jshow to code a python calculatorcalculating efence using pythonpython make a calculatorbuild a calculator in python forpython 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 calculatorhow to make a calculator in python 8 digitsbuild calculator with pythonpython calcualtorcalculator app in python python making a calculatorpython code for calculatorcalculator making in pythonhow 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 on pythonbuilding calculator javascripthtml calculatorhow to make simple calculator in pythoncode caculatorcalculator with javascript htmlcan 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 py 25 calculatorbasic calculator codedevelop a menu driven python program to design a simple calculator how to give input into calc exe using pythonpython how to make a calculatorphython calculatorarithmetic calculator in pythoncreate calculator using 4 functionsbasic calculation app in htmlpython calorie calculatorcode calculatrice pythonfunction to calculate python how to create a simple calculator in pythonbuild a calculator in pythonpython cidr calculatorhow to make a calculator jswrite a calculator in pythonhow to use python on your calculatorkundi calculatorhow to make calculation in pythoncalculator in htmlcode for calculator in python 2 7how to make calculator pythonsimple calculator using pythononelinecalculator pythonwap to model a simple calculator using functions for the following operationsjavascript calculator codesimple calculator program in pythonmake calculatoroperations examples for calculator projectsimple calculator in python using swithcerpython calculatorcalculator basic in pythoncalculator in python codecalculator using javascriptcalculator 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 realtivebearing python calculatorpython input calculatorhow to make a claculator in pythoncalculator code in python for calculator codecal calculatorcalculator 27calculator app using javascripta calculator code with pythonwrite 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 calculator in pythonhtml5 make calculatorpython calculataorcode in python for calculatorvlsm calculator pythonhow to write calculations in pythononline calculator using pythonbuild simple calculator using pythoncalculator 5csimple calculator python scripthow to make your own calculator softwarecalculator in html and javascripthow to build a calculator in pythonpython calculator anshow to code a calculator in pythoncalculatord you can do with pythonpython calculator onlinescientific calculator algorithm in javascriptcalculatror 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 jupytermake a calculator jscreating 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 calculatorjs calculatorhow to make calculator in javascripthtml calculatorcreate code of calaculator 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 functionscode to make a calculatorhow to make a python calculatorcalculator pyhton projectcalculator pythoncalculator htmlmaking a calculator with javascriptcalculator on pyhotnhow to write calculator program in pythonhow to create a calculator with pythoncalculatorcalculator 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 build a calculator in jshow to make a calculator with pythoncalculator html jscomputation code pythonpython projects using calculationscalculatorlcalculator code in pythoncalculator using pythonpython calaculatortaking an operation as input how to calculate pythonsimple calculator in python without functionsimple calculator application pythonpythag calculatorpython calculator projectcalculator codinghow to make a calculator in puthonmake a simple calculator using python mathematical operations how to code a calculatorhow to make a calculator in html with javascriptpython calculatiorcalculator in python3simple calculator using function in pythonpython program for calculatorhow to make a calculatorcode for calculator in pythonpython simple calculatorcalculatore codepython program to create a calculatorcoucalator in pythononline calculator codecool calculators we can create with pythoncalculater app in pythoncalculator python codehow to make calculator with pythoncalculator syntax for pythonpythion calculatorhow to make a calcualtor pythonmaking calculator in javascriptmake calculator in pythonpython calculator basic codecalculator 25python calculator file linecalculator pythonhow to make a online calculator in pythoncalculator program pythoncalculator using function in pythoncreate a function calculator in pythoncreate calculator pythonhow to make calculator by using pythoncalculator onlinemaking calculator in pythonpython arithmic calcilatorcalculator code using pythoncalculator html and javascriptuse in python calculationpython calculator codeingbuilding a calculator in pythonprogram calculatorcalculator in pyhtoncaluclator model in java scriptpython code for a calculatorcalculator calculator python programsimple calculator code in pythoncode ofr a calculatorpython calculator program using main functioncalc function in pythonhow to create a calculator program in pythoncalculator function in pythoncalculator python librarycalculator made with pythondo a calculator in pythonhow to make python calculator which calculates two or 3 valueshow to store calculator numbers in pythonbasic calculator program in pythonhow to code a simple calculator in pythoncalculate in pythonhtml calculatorspython program calculatorpackages needed to build calculator pythonpython simple calculator programpython function calculatorpython code to make a calculatorhow to make a basic calculator in pythoncode to make calculator in pythoncoding a simple calculator in pythonpython print calc 3d calculatorgenerate python function given input and output data online calculatorpython calculatepython basic calculation between two numberscreate and test an html document that has a basic calculator calculator javascript codepython calculator display a menu with operation options inputhow to calculat in pythonpython 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 pythonwrite menu based program in python to create a four way calculatorimplement basic calculator pythoncode python calculatorpython as calculatordef function python calculationcalculator jspython make calculator calculator onlinebasic calculator with pythonrun calculator pythonsimple basic calculator with pythoncalculator program using functions in pythonsimple calculator with pythonmake a calculator using javascriptcalculator that runs pythoncalculator ui htmldoes 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 pythonpython calcultorsimple calculator python codepython calculattorcalcualator with pythoncalcuator codehtml calculator examplecalculus calculator in pythondevelop a menu driven python program to design a simple calculator for arthematic and relational operatorpython build calculator stringcalculator program in pythoncalculator questions program in pythoncalculation method 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 pythonuse built in calculator pythoncreating calculator in pythonbest python calculatorshow to make a coucalator pythonpython console calculator calutator htmlhow to make a calculator with javascriptwhich type of coding in calculatercode for simple calculator in pythoncalculator with python