Answers for "calculus calculator in python"

1

basic calculator in python

#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!!!')
Posted by: Guest on December-25-2020
6

python calculator

num_one = int(input("Enter 1st number: "))

op = input("Enter operator: ")

num_two = int(input("Enter 2nd number: "))

if op == "+":
    print(num_one + num_two)
elif op == "-":
    print(num_one - num_two)
elif op == "*" or op == "x":
    print(num_one * num_two)
elif op == "/":
    print(num_one / num_two)
Posted by: Guest on August-01-2020
0

how to make a calculator in python

# 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)
Posted by: Guest on October-11-2020

Python Answers by Framework

Browse Popular Code Answers by Language