Calculator V1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
try:
x=1
y=1
x/y
except ZeroDivisionError:
print("y is zero")
finally:
print("this line will run, not matter what")
Is = ['1','+',1]
Is = '1 + 1'
Is=Is.split()
x= Is[0]
op= Is[1]
y= Is[2]
result = None
if type (float(x)) == float and type(float(y)) == float:
x=float(x)
y=float(y)
if op in ['+','-','*','/']:
if op =='+':
result=x+y
if op =='-':
result=x-y
if op =='*':
result=x*y
if op == '/':
result=x/y
else:
print("wrong operator")
else:
print("wrong operand")
print (result)
Is = '1 + 1 + 1 + 1'
Is=Is.split()
result = None
while (len(Is)>=3):
x= Is[0]
op= Is[1]
y= Is[2]
if type(float(x)) == float and type(float(y)) == float:
x=float(x)
y=float(y)
if op in ['+','-','*','/']:
if op =='+':
result=x+y
if op =='-':
result=x-y
if op =='*':
result=x*y
if op == '/':
result=x/y
else:
print("wrong operator")
else:
print("wrong operand")
del Is[:2]
Is[0]=result
print (result)
result = None
Is ='1 + 1 + 1'
Is =Is.split()
while (len(Is) >=3):
x=Is[0]
op=Is[1]
y=Is[2]
if type(float(x)) == float and type(float(y)) == float:
x=float(x)
y=float(y)
if op in ['+','-','*','/']:
if op =='+':
result=x+y
if op =='-':
result=x-y
if op =='*':
result=x*y
if op == '/':
result=x/y
else:
print("wrong operator!")
break
else:
print("wrong data type")
break
del Is[:2]
Is[0]=result
if len(Is) ==2:
print('wrong operand')
break
if len(Is) == 1:
break
else:
print("wrong operand")
print (result)
Python
INFO