This repository has been archived on 2025-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Files
python_it_top/02-10/tasks.py
it-top 02970172af add
2025-10-02 13:37:55 +05:00

43 lines
910 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import random
# * это оператор развертки, тоесть убирает скобки и запятые в списках
#list = []
#diap_min = -999
#diap_max = -20
#N = 20
#for _ in range(N):
# list.append(random.randint(diap_min, diap_max))
#print("Не сорт:", *list)
#for i in range(N):
# for g in range(N-1-i):
# if list[g] < list[g+1]:
# list[g], list[g+1] = list[g+1], list[g]
#print("Сорт:", *list)
N=45
diap_min=0
diap_max=20
list=[]
list_chet=[]
index=0
for _ in range(N):
list.append(random.randint(diap_min,diap_max))
for i in range(N):
for g in range(N-1-i):
if list[g] > list[g+1]:
list[g], list[g+1] = list[g+1], list[g]
while True:
if list[index] % 2 == 0:
list_chet.append(list[index])
index += 1
if index == N:
break
print("Четный список:", *list_chet)