예제 #1
0
def multiply (e):
    calc.setMathSign(2)
    if calc.num_num == 0:
        example.config(text=str(calc.get_num())+calc.get_sign())
    else:
        example.config(text=example.cget("text")+str(calc.get_num()))
예제 #2
0
def divide (e):
    calc.setMathSign(3)
    if calc.num_num == 0:
        example.config(text=str(calc.get_num())+calc.get_sign())
    else:
        example.config(text=example.cget("text")+str(calc.get_num()))
예제 #3
0
import calc as c
from sys import exit
import random

def generate():
	global a, b
	a = random.randint(0, 1000)
	b = random.randint(0, 1000)

generate()
c.setMathSign(0)
c.a = a
c.b = b
print('\n\n'+str(a) +'+'+ str(b) + '='+ str(c.calculate()))
if str(float(a+b)) == str(c.calculate()):
	print('Add successful\n')
else:
	print('\n\nBuild unsuccessful\n'+str(float(a+b)))
	exit(1)

generate()
c.setMathSign(1)
c.a = a
c.b = b
print(str(a) +'-'+ str(b) + '='+ c.calculate())
if str(float(a-b)) == str(c.calculate()):
	print('Remove successful\n')
else:
	print('\n\nBuild unsuccessful')
	exit(1)