Advertisement
tdrobotica

Ejercicio operaciones python

Mar 14th, 2022
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. #Operadores aritmeticos
  2. #Crea la función cuadradica
  3. from math import sqrt # importa libreria sqrt(raiz cuadrada) de el metodo math
  4. a = 20 #variable de tipo numerico
  5. b = -25 #variable de tipo numerico
  6. c = 5 #variable de tipo numerico
  7. determinante = b**2-4*a*c #declaración de variable
  8. if determinante < 0: # condicional if si el total determinante debe ser menor que 0
  9.     print("No existen soluciones reales. ")
  10. else: #Condicion sino
  11.     x1 = -b+sqrt(b**2-4*a*c)/(2*a) #variable 1
  12.     x2 = -b-sqrt(b**2-4*a*c)/(2*a) #variable 2
  13.  
  14.     print("Solución a la ecuación. ")
  15.     print("Solución x1: ",x1) #imprime la solucion
  16.     print("Solución x2: ",x2) #imprime la solucion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement