Ответ:
#1.1 задача
a=[0]*5
for i in range(5):
a[i]=int(input('Введите число: '))
print(*a, sep="\n")
#1.2 задача
from random import randint
a=[0]*10
for i in range(10):
a[i]=randint(0,20)
print(*a,end='')
#1.3 задача
a=[0,1,2,3,4,5,6,7,8,9]
a[i]**=3
print(*a,sep='\n')
#2.1 задача
nechet=[]
if i%2!=0:
nechet.append(a[i])
print(*nechet, sep="\n")
#2.2 задача
chet=[]
if a[i]%2==0:
chet.append(a[i])
print(a)
print(chet)
#2.3 задача
a.sort()
a.sort(reverse=True)
#3 задача
n=randint(0,20)
a=[0]*n
neotr=[]
otr=[]
for i in range(n):
a[i]=randint(-10,10)
if a[i]>0:
neotr.append(a[i])
if a[i]<0:
otr.append(a[i])
print(neotr)
print(otr)
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
#1.1 задача
a=[0]*5
for i in range(5):
a[i]=int(input('Введите число: '))
print(*a, sep="\n")
#1.2 задача
from random import randint
a=[0]*10
for i in range(10):
a[i]=randint(0,20)
print(*a,end='')
#1.3 задача
a=[0,1,2,3,4,5,6,7,8,9]
for i in range(10):
a[i]**=3
print(*a,sep='\n')
#2.1 задача
a=[0]*10
nechet=[]
for i in range(10):
a[i]=int(input('Введите число: '))
if i%2!=0:
nechet.append(a[i])
print(*nechet, sep="\n")
#2.2 задача
from random import randint
a=[0]*10
chet=[]
for i in range(10):
a[i]=randint(0,20)
if a[i]%2==0:
chet.append(a[i])
print(a)
print(chet)
#2.3 задача
from random import randint
a=[0]*10
for i in range(10):
a[i]=randint(0,20)
a.sort()
print(a)
a.sort(reverse=True)
print(a)
#3 задача
from random import randint
n=randint(0,20)
a=[0]*n
neotr=[]
otr=[]
for i in range(n):
a[i]=randint(-10,10)
if a[i]>0:
neotr.append(a[i])
if a[i]<0:
otr.append(a[i])
print(neotr)
print(otr)