import random
s = [random.randint(-50,50) for i in range(100)]
flag = False
print("Номера отрицательных элементов:", end=" ")
for i in range(len(s)):
if s[i] < 0:
print(i, end=" ")
flag = True
if not flag:
print("Нет отрицательных элементов.")
print()
print(s)
Номера отрицательных элементов: 1 2 3 7 9 14 15 16 19 20 25 26 28 33 34 35 37 38 41 46 48 49 50 51 52 54 55 56 60 61 66 67 70 72 74 75 79 80 81 82 87 88 89 90 92 94 96
Последовательность чисел:
[30, -44, -14, -20, 48, 10, 32, -8, 46, -27, 1, 1, 5, 3, -23, -22, -41, 28, 29, -4, -34, 46, 34, 6, 7, -45, -17, 45, -27, 5, 4 6, 12, 44, -28, -29, -34, 27, -39, -18, 16, 21, -5, 14, 21, 24, 30, -44, 37, -18, -38, -36, -15, -43, 23, -49, -11, -32, 36, 5 , 17, -12, -30, 26, 14, 26, 32, -31, -44, 42, 48, -14, 37, -45, 10, -34, -22, 48, 28, 10, -23, -6, -35, -38, 1, 33, 35, 50, -1 8, -2, -29, -20, 33, -15, 3, -27, 6, -50, 6, 25, 5]
import random
s = [random.randint(-50,50) for i in range(100)]
flag = False
print("Номера отрицательных элементов:", end=" ")
for i in range(len(s)):
if s[i] < 0:
print(i, end=" ")
flag = True
if not flag:
print("Нет отрицательных элементов.")
print()
print()
print(s)
Вывод:Номера отрицательных элементов: 1 2 3 7 9 14 15 16 19 20 25 26 28 33 34 35 37 38 41 46 48 49 50 51 52 54 55 56 60 61 66 67 70 72 74 75 79 80 81 82 87 88 89 90 92 94 96
Последовательность чисел:
[30, -44, -14, -20, 48, 10, 32, -8, 46, -27, 1, 1, 5, 3, -23, -22, -41, 28, 29, -4, -34, 46, 34, 6, 7, -45, -17, 45, -27, 5, 4 6, 12, 44, -28, -29, -34, 27, -39, -18, 16, 21, -5, 14, 21, 24, 30, -44, 37, -18, -38, -36, -15, -43, 23, -49, -11, -32, 36, 5 , 17, -12, -30, 26, 14, 26, 32, -31, -44, 42, 48, -14, 37, -45, 10, -34, -22, 48, 28, 10, -23, -6, -35, -38, 1, 33, 35, 50, -1 8, -2, -29, -20, 33, -15, 3, -27, 6, -50, 6, 25, 5]