Making Complex Trinomials

Tired of making new complex trinomials for quizzes and tests on factoring polynomials?  If you have python installed, you can use this script for making quiz questions.

from random import randint
import math

############################################################

# complex will take the form ax^2 + bx + c
# binomial factors will be in the form (dx + e)(fx + g)

#randomly choose d, e, f, g
for questions in range(0, 20):
     a, b, c, d, e, f, g = 0, 0, 0, 0, 0, 0, 0

     ## use while statement to avoid zeroes
     while (d == 0):
      d = randint(-6,6)
     while (f == 0):
      f = randint(-7,7)
     while (e == 0):
      e = randint(-6,6)
     while (g == 0):
      g = randint(-10,10)

     a = d\*f 
     b = d\*g + e\*f
     c = e\*g

     print ("(" + str(d) + "x + " + str(e) + ")(" + str(f) + "x + " + str(g) + ")