You are on page 1of 2

BASIC CALCULATOR PROGRAM>>….

def multiply(list):
c = 1
for i in list:
a = float(i)
c = a * c

return c

def add(list):
c = 0
for i in list:
a = float(i)
c = a + c

return c

def subtract(list):
a=int(list[0])
for i in range(1,len(list)):
list[i]=int(list[i])
a=a-list[i]

return a

def division(list):
a=int(list[0])
for i in range(1,len(list)):
list[i]=int(list[i])
a=a/list[i]

return a

def listprint():
while "true":
n = input("enter the no.:")
if n == "STOP":
break
else:
list.append(n)

print(list)

list = []
print("add no.s and write STOP to stop adding")
listprint()

print("1 for add")


print("2 for subtract")
print("3 for multiply")
print('4 for division')
print("0 to stop continuing")
def main_func():
k=int(input("enter no. corresponding to operation u would like to
perform"))

if k==1:
print(add(list))
main_func()

elif k==2:
print(subtract(list))
main_func()

elif k==3:
print(multiply(list))
main_func()

elif k==4:
print(division(list))
main_func()

elif k==0:
pass

else:
print("invalid input ...type again")
main_func()

main_func()

You might also like