Advertisement
teslariu

modulo funciones

May 15th, 2021
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Script que calcula las posibles soluciones de una raíz cuadrada de un
  5. número real. Si no existe, imprime una cartel indicando tal situación
  6. """
  7.  
  8. def calcular_raiz(numero):
  9.     from math import sqrt
  10.     if numero < 0:
  11.         return "NO EXISTE la raiz cuadrada de un nro. negativo en el campo de los reales"
  12.     elif numero == 0:
  13.         return 0
  14.     else:
  15.         return [sqrt(numero),-1*sqrt(numero)]
  16.        
  17. def imprimir_raices(raices):
  18.     if isinstance(raices,str):
  19.         print(raices)
  20.     elif isinstance(raices, int):
  21.         print(f"Existe una única raiz: {raices}")
  22.     else:
  23.         print(f"Existen dos soluciones: {raices[0]} y {raices[1]}")
  24.        
  25.  
  26. def saludo(nombre="No me has dicho tu nombre"):
  27.     print(nombre)
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement