Question #251455

3. The sequence of natural numbers a1, a2, ..., an is given. There are positive and negative elements in the chain. Calculate the product of negative elements P1 and the product of positive numbers P2. Compare the modules P2 and P1, indicate which of the modulus is greater.

Expert's answer

s_1 = list(map(int,input("input sequence of natural numbers:\n").split()))
pos, neg = 1, 1
for num in s_1:
	if num > 0:
		pos *= num
	elif num < 0:
		neg *= num
if abs(pos) > abs(neg):
	print("product of positive numbers greater")
elif abs(pos) < abs(neg):
	print("product of negative elements greater")
else:
	print("product of negative elements eqval product of positive numbers")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS