Advertisement
here2share

# factorial_format.py

Dec 26th, 2019
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. # factorial_format.py
  2.  
  3. def factorial(x):
  4.     if x < 0:
  5.         return("Error!")
  6.     elif x==0:
  7.         return(0)
  8.     else:
  9.         return(x*x)
  10.  
  11. for x in xrange(-1,10+1):
  12.     print('{var} x {var} = {ans}'.format(var=x,ans=factorial(x)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement