Во!!! :-)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# coding: utf-8
import math
def printRoots(a, b, c):
"""функция printRoots() высчитывает корни квадратного уравнения ax**2 + bx + c = o, a != 0"""
print 'ax**2 + bx + c = o, a != 0'
print
print 'a = %f' % a
print 'b = %f' % b
print 'c = %f' % c
print
print "D = b**2 - (4 * a * c)"
print "x1 = (-b + math.sqrt(D)) / (2 * a)"
print "x2 = (-b - math.sqrt(D)) / (2 * a)"
print
D = b**2 - (4 * a * c)
print " In function D = %f" % D
x1 = (-b + math.sqrt(D)) / (2 * a)
x2 = (-b - math.sqrt(D)) / (2 * a)
print
print 'x1 = %f' % x1
print 'x2 = %f' % x2