# 1.
l = list(map(int,input("input space-separated integers:\n").split()))
sq = []
for i in range(len(l)):
if l[i]**(1/2) == int(l[i]**(1/2)):
sq.append(l[i])
print(*sq)
# 2.
s = list(map(int,input("input sequence of natural numbers:\n").split()))
z = int(input("Z = "))
cnt = 0
for i in range(len(s)):
if s[i] > z:
s[i] = z
cnt += 1
print(f"number of substitutions: {cnt}")
# 3.
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")
Comments
Leave a comment