teslariu

raise

Nov 30th, 2021
692
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. def sumar(a,b):
  5.     "Funcion que devuelve la suma de dos nros"
  6.     if not isinstance(a, (int,float)) or not isinstance(b, (int,float)):
  7.         raise TypeError("Los argumentos deben ser nĂºmeros")
  8.     return a+b
  9.    
  10.  
  11. total = sumar("2","3")
  12. print(total)   
  13.    
  14. total = sumar(2,3)
  15. print(total)
  16.  
  17. total = sumar((2,),(3,))
  18. print(total)
RAW Paste Data