Discuss / Python / 作业

作业

Topic source

weiqing1230

#1 Created at ... [Delete] [Delete and Lock User]

>>> def prod(*args):

...   I= len(args)

...   s = 0

...   while I >0:

...     s = 1

...     for n in args:

...       I=I-1

...       s = s * n

...   print(s)

...

>>> prod()

0

>>> prod(5)

5

>>> prod(5,5)

25

>>> prod(5,5,5)

125


  • 1

Reply