how to make a calculator in python

#Store number variables for the two numbers

num1 = input('Enter first number: ')
num2 = input('Enter second number: ')

#the sum of the two numbers variable
sum = float(num1) + float(num2)
sum2 = float(num1) - float(num2)
sum3 = float(num1) * float(num2)
sum4 = float(num1) / float(num2)

#what operator to use
choice = input('Enter an operator, + = addition, - = subtraction, * = multiplication and / = division: ')
#different sums based on the operators
if choice == '+':
  print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))

  if choice == '-':
    print('The sum of {0} and {1} is {2}'.format(num1, num2, sum2))

if choice == '*':
    print('The sum of {0} and {1} is {2}'.format(num1, num2, sum3))

if choice == '/':
    print('The sum of {0} and {1} is {2}'.format(num1, num2, sum4))
 

0
0
Phoenix Logan 186120 points

                                    #You can change Text at Inputs

num1 = float(input("Enter Firt Number:"))
num2 = float(input("Enter Second Number"))

result= 0
op = str(input("Enter an op(operator)"))
#Gets Input Type--------
try:
  #U can make this in while loop ;-)
  if op=="+":
    result = num1 + num2
  else if op=="-":
    result = num1 - num2
  else if op=="*":
    result = num1 * num2
  else if op=="/":
    result = num1 / num2
  else:
      print("Invalid Input")
  print("The result is " + result)
except ZeroDivisionError:
  print("U cant do that")

0
0
3.5
2
Krish 100200 points

                                    def add(num1, num2):
    return num1 + num2

def subtract(num1, num2):
    return num1 - num2

def multiply(num1, num2):
    return num1 * num2

def divide(num1, num2):
    return num1 / num2

3.5 (2 Votes)
0
3.67
3
Krish 100200 points

                                    #My Personal Python calculator
print("My Personal Python calculator")
#inputs
num1 = int(input('Enter the first number:  '))
num2 = int(input('Enter the second number:  '))
#opration req
opr = input('Enter the type of operation you want to perform between your chosen two numbers:  ')
#calculation
if opr=='+':
    ans = num1 + num2
    # displaying the answer
    print(f'Your final answer is {ans}')
elif opr == '- ':
    ans = num1 - num2
    # displaying the answer
    print(f'Your final answer is {ans}')
elif opr=='*':
    ans = num1 * num2;
    # displaying the answer
    print(f'Your final answer is {ans}')
elif opr=='/':
    ans = num1 / num2
    # displaying the answer
    print(f'Your final answer is {ans}')
else:
    print('Invalid Entry!!!')

3.67 (3 Votes)
0
3.8
5
Phoenix Logan 186120 points

                                    Select operation.
1.Add
2.Subtract
3.Multiply
4.Divide
Enter choice(1/2/3/4): 3
Enter first number: 15
Enter second number: 14
15.0 * 14.0 = 210.0

3.8 (5 Votes)
0
0
6
Phoenix Logan 186120 points

                                    # This will be one of the most advanced results you will find.

# We will be using classes and simple operators like +,-,*,/

class Calculator:
  def addition(a,b):
    return a + b

  def subtraction(a,b):
    if a<b:
      return b - a
    else:
      return a - b

  def multiplication(a,b):
    return a * b

  def division(a,b):	
    if a<b:
      return b / a
    else:
      return a / b

# You can do this in terminal.
<C:/Users/username>python
>>> from main import Calculator
>>> result = Calculator.[addition|subtraction|multiplication|division](anyNumber, anyNumber)
>>> print(result)

0
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
writing a calculator on python def calculator python building a calculator in python python calculator online 2. Python Program to Make a Simple Calculator calculus calculator in python python as a calculator code Python as a calculator. how to code a simple calculator in python how to make a calculator in python source code calculator define python make calculator with python creating a simple calculator in python what is phython calculator calculatrice in python programing a calculator to python python calculator function how to make calculator by using python building calculator in python how to solve basic calculator python create calculator in python Construct a python program to make a simple calculator. python make calculator simple calculator using function in python write a program to create a simple calculator in python python calculator script creating a calculator in python code python calculator python how to make a calculator python program for calculator python code for a working calculator calculator made with python create a calculator in python pytho calculator basic calculator with python python calculator example run calculator python calculator script python make calculator python how to create python calculator calculator program in python python program to build calculator calculator in python python calculataor calculatrice python coding make a calculator in python python calculator program on python basic calculator using python simple python calculator creating calculator in python how to make a calculator using python code for calculator in python how to do calculator in python implement a calculator in pythn calculator basic in python calculator on python python calculas how to make calculator python calculator that use python to program calculators that use python simple calculator python script how to make calculator with python do a calculator in python coding on a calculaotr in python calculator coding in python simple calculator in python using swithcer code for a calculator in python build simple calculator using python code to make a calculator in python python code for a calculator make calculator using python make calculatrice using python Write a Python Program to demonstrate basic Calculator functionality using the concept of functions in Python. How to make an Calculator in python write a calculator code in python calculator using python python calculator ans build a calculator using python calculatror python how to make python calculator how to make a caculator in python how to code a python calculator how to do a calculator in python python program to design a SIMPLE CALCULATOR(Using functions). simple calculator operations python script for calculator in python python code for calculator how to make a python calculator python program to make a simple calculator (using functions) python make a calculator python script for calculator calculator python program Write a python program to design a SIMPLE CALCULATOR(Using functions). how to write calculator program in python python program to simple calculator calculator with python make calculator in python using funtions make calculator in python code for making calculator in Python does python have calculator basic python calculator code in python for calculator how to make a calculator in python calculator in python for beiners how to make calculator in python how to create calculator in python how to create a simple calculator in python simple python program for calculator with what module can i create calculator in python calculator python tutorial simple calculator in python calculator python python calculator how to make a calculator in python for beginners simple calculator in python using functions python calculator codeing best calculator using python how to make a simple calculator in python creating a calcualtor in python python program to make simple calculator python basic calculator building calculator python calculator define using function in python calculator using function in python how to use python as a calculator python making a calculator python function calculator python script calculator calculator in python3 taking an operation as input how to calculate python how to make your own calculator software how to make a boolean function in python code for calculator how to make a coucalator python use built in calculator python creating a calculator python python make a simple calculator python calucaltor code vlsm calculator python best python calculators simple calculator using def return in python The programe should performe the operation selected python create calculator with module basic calculator code making a calculator in python using functions python build calculator string simple calculator project in python arithmetic calculator python Python program make calculator calculator python \ python projects using calculations function to calculate python python calculator file line python calculator program basic calculator in python using functions calculator python script calc in python how to have a calculating input in python making a calculator in python how to make python calculator which calculates two or 3 values basic calculator which can perform 2 or 3 number calculations python pythin calc package calculate x python calculator code in python for calculator code in python calculater app in python calculator code python 3 python simple calculator expression python module calculator program python input() to calculator create a calculator from modules in python making a simple calculator python module strcutured package for calculator using python calculator price in python using functions how to make calculator in pythone xplained how to add a calculation function in python python simple calculator making a text based calculator in python how to give input into calc.exe using python coding a simple calculator in python computation code python create bsaic calculator python calculator program how to build a calculator in python calcualator with python how to make an ode calculator python how to make a calculator inpy calculator in pythonb basic calculator in python python calculator sample code simple calculator docs python use in python calculation create a calculator using python make calculator pythob python calculator python code calculator how to create a web based calculator with python calculator questions program in python calculator in python code calc function in python python arithmic calcilator python module calculator calculator python 3 do a calculator in pytho create calculator python how to create calculator app in python implement calculator simple calculator using python online python calculator simple calculator command in python calculator based project python class 12 make console calculator in python simple calculator with python python interpreter as calculator code Pyhton calculator python input calculator program calculator Write a Calculator in Python python program that creates estimator python estimator program python simple calculator program calculatord you can do with python Homework 5: Multiplication Calculator python def function python calculation python calculator basic code how to make a silmple calculaytor in python calculator using functions in python simple calculator python python calculator code code for python calculator import calculator in python calculator program python calculator phython ptython code of calculator calculator python code cool calculators we can create with python basic calculator python how to code a calculator in python python calc calcaulator in python making calculator in python calculator pyhton project calculate in python and display in c calculate lcpd python how to add a calculation in python calculator algorithm python input calculator python operations examples for calculator project python console calculator calculator project in python Q1. Create a calculator where user have a menu to perform addition / subtraction / multiplication / division / display tables . Using loops in python. calculator python Create a calculator where user have a menu to perform addition / subtraction / multiplication / division / display tables . Using loops in python. packages needed to build calculator python write calculator program besic calculator in phyton python Calculator Display a menu with operation options input calculator from python how to create a calulator in python python simple calculator whith only integer py calculator basic py calculator code for calculator app in python make a basic calculator in python python code for calculator downloading file how to code calculator in python without function how to code calculator in python calculator on pyhotn Basical calculator python python list calculator generate python function given input and output data online calculator code for making a calculator in python calculator excersise in python complication pyhton calculator python calculator code copy and paste calculator code python how to make a addition calculator in python simple calculator code in python calculator python source code simple calculator program in python best python calculator python code for calcculator how to code a simple calculator in python using functions make a caleculatoer in python python caculator how to make a simple calcualator in python calculator in python function calculate function do in python calculator python code glebber. python calculator example with chekc python calaculator python calculaor file how to calculate using python how to make a calculator python 2 how to make a caclulator in python calclator python codr python calculetor lagoritham how to make a simple calculator using python calculator with custom function in python WAP to model a simple calculator using functions for the following operations simple computation python www.creating calculator by using python develop a menu driven python program to design a simple calculator. for arthematic and relational operator small python calculator python calcultor bsic claculator in python images how to create a calculator in python simple calculator application python calculator in python
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source