Advertisement
Fhernd

definir-funciones.py

Feb 1st, 2018
674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. def cubo_tres():
  2.     """
  3.     Retorna el cubo de 3.
  4.     """
  5.     return 3 * 3
  6.    
  7. print(cubo_tres())
  8.  
  9. print()
  10.  
  11. def factorial(num):
  12.     """
  13.     Calcula el factorial de un número dado.
  14.     """
  15.     fact = 1;
  16.     idx = 1;
  17.     while idx <= num:
  18.         fact *= idx
  19.         idx += 1
  20.        
  21.     return fact
  22.    
  23. print(factorial(7))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement