Answers for "best 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
0

simple calculator in python

#Simple Calculator Program in Python by Rupesh Singh

def sum1(first_input, second_input):    # Sum function "+"
    result1 = first_input + second_input
    print("Your Answer is:-", result1)
    return

def minus(first_input, second_input):    # Minus function "-"
    result2 = first_input - second_input
    print("Your Answer is:-", result2)
    return

def multi(first_input, second_input):    # Multiplication function "*"
    result3 = first_input * second_input
    print("Your Answer is:-", result3)
    return

def div(first_input, second_input):    # Division function "/"
    result4 = first_input / second_input
    result4 = float(round(result4))
    print("Your Answer is:-", result4)
    return

# User Input
first_input = int(input("Enter your 1st Input:- "))
command = input("What you want to do (+, -, *, /):- ")
second_input = int(input("enter your 2nd Input:- "))

if command == "+":
    sum1(first_input, second_input)
elif command == "-":
    minus(first_input, second_input)
elif command == "*":
    multi(first_input, second_input)
elif command == "/":
    div(first_input, second_input)
else:
    print("Command Error!")
Posted by: Guest on April-03-2021

Python Answers by Framework

Browse Popular Code Answers by Language