Answers for "calculatore python"

0

how to make a python calculator

#Calculator

import time

def add():
  n1 = input('Enter a number: ')
  n2 = input('Enter another number: ')
  time.sleep(1)
  print(int(n1)+int(n2))
  
def multiply():
  n1 = input('Enter a number: ')
  n2 = input('Enter another number: ')
  time.sleep(1)
  print(int(n1)*int(n2))
    
def divide():
  n1 = input('Enter a number: ')
  n2 = input('Enter another number: ')
  time.sleep(1)
  print(int(n1)int(n2))
  
def subtract():
  n1 = input('Enter a number: ')
  n2 = input('Enter another number: ')
  time.sleep(1)
  print(int(n1)-int(n2))
  
run = True
while run:
  ans = input('Select an opreation: ')
  if(ans=='Addition'):
    add()
    
  if(ans=='Divide'):
    divide()
    
  if(ans=='Multiply'):
    multiply()
    
  if(ans=='Subtract'):
    subtract()
Posted by: Guest on October-24-2020
-1

python calculator

print("Choose operator (+,-,*,/):")
mode = input()
print("Choose first int:")
x = int(input())
print("Choose second int:")
y = int(input())

print("Your result:")
if mode == "+":
    print(x+y)
elif mode == "-":
    print(x-y)
elif mode == "*":
    print(x*y)
elif mode == "/":
    print(x/y)
Posted by: Guest on November-02-2020

Python Answers by Framework

Browse Popular Code Answers by Language