Posted by noobs_first_py_s on July Sat 28th 10:14 PM - Never Expires
Download | New paste

  1. import math
  2.  
  3. print "This program figure out roots for quadratic equation ax**2+bx+c=0"
  4.  
  5. a = input("select a:") #define "a"
  6. b = input("select b:") #define "b"
  7. c = input("select c:") #define "c"
  8.  
  9. if  0>b**2-4*a*c:
  10.     print "D<0 equation can't be solved"
  11.  
  12. else:   
  13.      D = b**2-4*a*c #count D
  14.  
  15.      x1=(-b+math.sqrt(D))/(2*a)
  16.      x2=(-b-math.sqrt(D))/(2*a)
  17.  
  18.      print "x1=",x1,"\nx2=",x2
Language:
To highlight particular lines, prefix each line with @@