Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from modulepythong import *
- from math import sqrt
- a=float(raw_input('Ingrese a: '))
- b=float(raw_input('Ingrese b: '))
- c=float(raw_input('Ingrese c: '))
- discriminante = b**2 - 4*a*c
- if discriminante >= 0:
- x1 = (-b + sqrt(discriminante )) / (2 * a)
- x2 = (-b - sqrt(discriminante )) / (2 * a)
- if x1>x2:
- x1,x2=x2,x1
- print 'Las soluciones son: '
- print x1,x2
- valor=(-b)/(2*a)
- y=abs((a*(valor**2))+(b*valor)+c)
- m=max( abs(x1),abs(x2))
- window_size(500, 500)
- window_coordinates(-m-3, -y-3, m+3, y+3)
- create_line( 0 , y+2.5 , 0 , -y-2.5, 'blue')
- create_line( -m-2.5 , 0 , m+2.5 , 0 , 'blue')
- plus=float(0.01)
- x=float(x1-2)
- while x <= x2+2 :
- y=((a*(x**2))+(b*x)+c)
- z=(a*((x+plus)**2)+(b*(x+plus))+c)
- create_line(x, y, x+plus, z, 'red')
- x = x+plus
- create_text(x1+0.5, 0.5, x1, 10, 'SW')
- create_text(x2+0.5, 0.5, x2, 10, 'SW')
- print'Pulsa <Return> para salir: '
- raw_input()
- else:
- print 'No hay soluciones reales'
Advertisement
Add Comment
Please, Sign In to add comment