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") 

when I try to enter a negative number or a number over 99 the integer box wont let me, Is there any way around this

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))
1

There are 1 answers

1
Shashank On

Try changing the default parameters of the function integerbox when you call it. Specifically, the one you'll want to change to allow negative numbers is lowerbound. Here is the full definition of integerbox so you can see all the parameters.

integerbox(msg='', title=' ', default='', lowerbound=0, upperbound=99, image=None, root=None, **invalidKeywordArguments)

The minimum value for an integer on any platform can be accessed through the following method:

import sys
a=eg.integerbox(msg='enter a', lowerbound = -sys.maxint - 1)

The upperbound for an int can be accessed through sys.maxint.