import math
import easygui as eg
eg.msgbox("This program solves quadratic equations Enter the values of a, b and c ")
a=eg.integerbox("enter a")
b=eg.integerbox("enter b")
c=eg.integerbox("enter c")
i = b**2-4*a*c
if d < 0:
eg.msgbox("There are no real solutions")
elif i == 0:
x = (-b+math.sqrt(i))/(2*a)
eg.msgbox("heres your solution: "), x
else:
x1 = (-b+math.sqrt(i))/(2*a)
x2 = (-b-math.sqrt(i))/(2*a)
eg.enterbox(msg="you have 2 solutions", default=(x1,x2))
答案 0 :(得分:2)
尝试在调用时更改函数integerbox
的默认参数。具体而言,您要更改为允许负数的那个是lowerbound
。以下是integerbox
的完整定义,以便您可以查看所有参数。
integerbox(msg='', title=' ', default='', lowerbound=0, upperbound=99, image=None, root=None, **invalidKeywordArguments)
可以通过以下方法访问任何平台上的整数的最小值:
import sys
a=eg.integerbox(msg='enter a', lowerbound = -sys.maxint - 1)
可以通过sys.maxint
访问int的上限。