Advertisement
teslariu

try

Nov 30th, 2021
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Script que pide dos numeros y devuelve su cociente
  5.  
  6. def ingresar_numero(tipo):
  7.     while True:
  8.         try:
  9.             n = int(input(f"Ingrese el {tipo}: "))
  10.         except ValueError:
  11.             print("No ha ingresado un nĂºmero entero")
  12.         else:
  13.             if tipo == "divisor" and not n:
  14.                 print("El divisor debe ser no nulo")
  15.                 continue
  16.             return n
  17.    
  18.  
  19.  
  20. a = ingresar_numero("dividendo")
  21. b = ingresar_numero("divisor")
  22.  
  23. print(f"El cociente entre {a} y {b} es {a/b}")
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement