[Tutor] Simple factorial program

wesley chun wescpy at gmail.com
Thu Jun 11 18:44:37 CEST 2009


hi eddie, a few more nits to tweak...


> factorialNum = 1L

change to "1" instead of "1L" -- "L" numbers are going away and will
be permanently not available starting in 3.0.


> print "Factorial finder"
> number = int(input("Please enter a non-negative integer: "))

change "input" to "raw_input"... that is, *until* 3.0 when input()
will be replaced by raw_input() and renamed to input()!


> for number in range(1, number):

since you started at "1", to avoid skipping, change "1" to "2".


>   factorialNum = (factorialNum * (number + 1))

so that you can change this to: "factorialNum *= number"

hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
"Python Fundamentals", Prentice Hall, (c)2009
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Tutor mailing list