Published on Jul 19 , 2020
create a calculator in python full tutorial.
Codes
def calculator():
import math
def add(x,y):
return x+y
def subtract(x,y):
return x-y
def multiply(x,y):
return x*y
def divide(x,y):
return x/y
def exponent(x,y):
return x**y
def squareroot(x):
return math.sqrt(x)
print('Calculator')
print('1=add')
print('2=subtract')
print('3=multiply')
print('4=divide')
print('5=exponent')
print('6=squareroot')
i=int(input('enter any scenario 1/2/3/4/5/6 : '))
if i in (1,2,3,4,5,6):
if i==1:
x=float(input('enter the first number : '))
y=float(input('enter the second number : '))
print(add(x,y))
elif i==2:
x=float(input('enter the first number : '))
y=float(input('enter the second number : '))
print(subtract(x,y))
elif i ==3:
x=float(input('enter the first number : '))
y=float(input('enter the second number : '))
print(multiply(x,y))
elif i==4:
x=float(input('enter the numerator : '))
y=float(input('enter the denominator : '))
print(divide(x,y))
elif i==5:
x=float(input('enter the base number : '))
y=float(input('enter the power : '))
print(exponent(x,y))
elif i==6:
x=float(input('enter the number : '))
print(squareroot(x))
else:
print('Out of calculation method ')
this video on how to make calculator in python in very simple language.
Simple Hacks with Anshul Rana provide all these types of video please subscribe my channel.
Creator - Anshul Rana
With the help of - Vikas Rana
If you interested in Free fire gaming Subscribe the channel - / @sachinpainuly6850