[Tutor] recursive?

Andrea Spitaleri spiritelllo at interfree.it
Sat Sep 13 12:19:55 EDT 2003


Hiya boys ;-)
my first post:
# andrea
import math
print "******************************************************************"
print                             "Hi this is a test to resolve 2nd 
equation"
print "******************************************************************"
print "tell me the values for a, b and c of the equation ax^2+bx+c=0"
a=input('a:')
b=input('b:')
c=input('c:')
if b**2 - 4*(a*c) < 0:
        print "il risultato sono valori complessi" #  with import cmath 
and cmath.sqrt you can get complex numbers
        q=raw_input("Do you want try again?")
        if q == 'y':         #without ' ' you get error
               
        else:
                print 'bye'
else:
        print " x1 =", ((-b/2)+(math.sqrt(((b**2)/4)-a*c)))/a, "and x2 
=", ((-b/2)-(math.sqrt(((b**2)/4)-a*c)))/a

that small silly program works but I would like to insert another 
condition. after typing y after 'do you want try again?' how I can start 
again all the program, asking again the three values?

thanks

andrea





More information about the Tutor mailing list