Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- Script que calcula las posibles soluciones de una raíz cuadrada de un
- número real. Si no existe, imprime una cartel indicando tal situación
- """
- def calcular_raiz(numero):
- from math import sqrt
- if numero < 0:
- return "NO EXISTE la raiz cuadrada de un nro. negativo en el campo de los reales"
- elif numero == 0:
- return 0
- else:
- return [sqrt(numero),-1*sqrt(numero)]
- def imprimir_raices(raices):
- if isinstance(raices,str):
- print(raices)
- elif isinstance(raices, int):
- print(f"Existe una única raiz: {raices}")
- else:
- print(f"Existen dos soluciones: {raices[0]} y {raices[1]}")
- def saludo(nombre="No me has dicho tu nombre"):
- print(nombre)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement