Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # script que pide dos números y devuelve su cociente, suma, producto y
- # resta
- def ingresar_numero(tipo):
- while True:
- try:
- numero = float(input(f"Ingrese un número {tipo}: "))
- except ValueError:
- print("No ha ingresado un número")
- else:
- if tipo=="b" and not numero:
- print("El nro b debe ser distinto de cero")
- else:
- return numero
- if __name__ == '__main__':
- a = ingresar_numero("a")
- b = ingresar_numero("b")
- print(f"La suma entre {a} y {b} es {a+b}")
- print(f"La resta entre {a} y {b} es {a-b}")
- print(f"El producto entre {a} y {b} es {a*b}")
- print(f"El cociente entre {a} y {b} es {a/b}")
Advertisement
Add Comment
Please, Sign In to add comment