[Tutor] factorial of anumber

Blockheads Oi Oi breamoreboy at yahoo.co.uk
Sat Feb 4 11:24:03 CET 2012


On 04/02/2012 10:11, Debashish Saha wrote:
> _PROGRAM TO FIND FACTORIAL OF A NUMBER(I HAVE WRITTEN IT ON GEDIT)_
> x=1
> n=input('enter a positive integer no:')
> for i in range(1,1+n):
>      x=x*i
> print x
>
>
> _ERROR:_
>
> enter a positive integer
> no:---------------------------------------------------------------------------
> EOFError                                  Traceback (most recent call last)
> C:\Python27\lib\site-packages\IPython\utils\py3compat.pyc in
> execfile(fname, glob, loc)
>      166             else:
>      167                 filename = fname
> --> 168             exec compile(scripttext, filename, 'exec') in glob, loc
>      169     else:
>      170         def execfile(fname, *where):
>
> C:\Users\as\mnb.py in <module>()
>        1 x=1
> ----> 2 n=input('enter a positive integer no:')
>        3 for i in range(1,1+n):
>        4     x=x*i
>        5 print x
>
> EOFError: EOF when reading a line
>
> *QUESTION*:
> HOW TO ASK INPUT FROM USER THEN?
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

It works fine for me.

 >>> enter a positive integer no:>>> 6
720

And please DO NOT USE CAPITAL LETTERS or people may stop answering your 
questions.

-- 
Cheers.

Mark Lawrence.



More information about the Tutor mailing list