Ответ:
1)
import random
a = []
for i in range(7):
a.append(random.randint(5, 13))
b = []
for i in range(len(a)):
if a[i] % 2 == 0:
b.append(a[i])
print(b)
2)
a = [4, 3, 8, 2, 32432, -5, 1]
if a[i] % 2 == 1:
print(a[i])
List = [random.randint(5, 13) for i in range(7)]
print(List)
chet = []
nechet = []
for i in List:
if not i%2:
chet.append(i)
if i%2:
nechet.append(i)
print('a)',chet)
print('б)',nechet)
Объяснение:
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
1)
import random
a = []
for i in range(7):
a.append(random.randint(5, 13))
b = []
for i in range(len(a)):
if a[i] % 2 == 0:
b.append(a[i])
print(b)
2)
a = [4, 3, 8, 2, 32432, -5, 1]
for i in range(len(a)):
if a[i] % 2 == 1:
print(a[i])
Ответ:
import random
List = [random.randint(5, 13) for i in range(7)]
print(List)
chet = []
nechet = []
for i in List:
if not i%2:
chet.append(i)
if i%2:
nechet.append(i)
print('a)',chet)
print('б)',nechet)
Объяснение: