Предмет: Информатика, автор: temirbaevvadim

2. Прочитайте условия задачи и напишите программный код. i. Дан массив B[N], состоящий из 6 элементов. Отсортируйте массив В по убыванию и запишите его в новый массив D.​

Ответы

Автор ответа: MagicSticks
1

Ответ:

B = [5, 2, 9, 1, 7, 3]   # исходный массив

D = sorted(B, reverse=True)   # сортировка по убыванию и запись в новый массив

print(D)   # вывод отсортированного массива D

Объяснение:

В данном примере мы создаем исходный массив B, состоящий из 6 элементов. Затем мы используем функцию sorted() для сортировки массива B в порядке убывания и записи отсортированных элементов в новый массив D. В параметре reverse=True мы указываем, что нужно сортировать в порядке убывания.

После этого мы выводим отсортированный массив D при помощи функции print().

Похожие вопросы
Предмет: Английский язык, автор: bogryashovaanastasya
Пожалуйста, помогите.
1. They spoke so quickly that I... what they were speaking about.
a) not understand;
b) don't understand;
c) didn't understand;
d) hadn't understood.
2. Yesterday our flight... because of the fog.
a) cancelled
b) was cancelled
c) had been cancelled
d) has been cancelled
3.The Vikings... to North America a thousand years ago.
a) sail
b) sailed
c) had sailed
d) have sailed
4.Thank you for your offer. But I... not to accept it.
a) decide
b) has decided
c) have decided
d) decided
5. You... through your old photograph album for half an hour already.
a) look
b) are looking
c) have looked
d) have been looking
6. Nobody knows where his picture is. Perhaps it....
a) was stolen
b) will be stolen
c) has been stolen
d) stolen
7. I agree. You ... apologize for not inviting him to your birthday party.
a) can't
b) mustn't
c) shouldn't
d) may not
8. Actually,today I feel... than I did yesterday.
a) bad
b) worse
c) worst
d) the worst
9. ... people who are unemployed often feel depressed.
a) the
b) -
c) a
d) that
10. Who was the first astronaut who landed on... Moon?
a) the
b) -
c) a
d) those
11. What happened at the end of the film? -I'm sorry to say, but I haven't seen... film.
a) a
b) the
c) -
d) those
12. This is... interesting exhibition I've ever visiting.
a) more
b) most
c) less
d) the most
13. Would you mind waiting... minutes?
a) few
b) a few
c) little
d) a little
14. I'm... interested in languages than in mathematics.
a) much
b) many
c) little
d) less
15. The students often translate English texts... Russian.
a) to
b) in
c) into
d) on