CoCalc Shared Files2017-06-04-164339.sagewsOpen in CoCalc with one click!
Author: Leon Denis
Views : 8
def poly(r, grau): raizes = [randint(-5,5) for i in range(r) ] a = randint(-1,1) if grau<len(raizes): print 'o numero de raizes deve ser meno ou igual ao grau' else: p = (x-a)^(grau-len(raizes)) for r in raizes: p *= (x-r) return latex(p.expand()) num_raizes = 3 grau = 4 arquivo = open('poly.txt','w') for i in range(10): arquivo.write(poly(num_raizes, grau) + '\n') arquivo.close()