runnig

Product of Odd elements in array

Oct 13th, 2017
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. def arrayOddProduct(arr):
  2.     """Returns a product of odd elements in array arr."""
  3.     s = 1
  4.     for a in arr:
  5.         if ??: # REPLACE ??
  6.           s *= a
  7.     return s
  8.  
  9. if __name__ == "__main__":
  10.     arr = [1,2,3,4,5,6,7]
  11.     result = arrayOddProduct(arr)
  12.     expected = 105
  13.     assert result == expected, ("product of array %s must be %d, but it is %d" % (arr, expected, result))
Advertisement
Add Comment
Please, Sign In to add comment