Предмет: Информатика,
автор: Gjutktge
Створити (у консолі) список із 7 цілих чисел.
Використовуючи функції для роботи зі списками, знайти:
1) довжину списку;
2) найбільший елемент списку;
3) суму елементів писку;
4) найменший елемент списку;
5) видалити елемент списку з індексом
Ответы
Автор ответа:
0
Ответ:
# create a list of 7 integers
my_list = [5, 8, 13, 4, 22, 1, 9]
# find the length of the list
list_length = len(my_list)
print("The length of the list is:", list_length)
# find the largest element of the list
largest_element = max(my_list)
print("The largest element of the list is:", largest_element)
# find the sum of the elements of the list
sum_of_elements = sum(my_list)
print("The sum of the elements of the list is:", sum_of_elements)
# find the smallest element of the list
smallest_element = min(my_list)
print("The smallest element of the list is:", smallest_element)
# delete the item with index 3 (fourth element)
del my_list[3]
print("The updated list after deleting the item with index 3 is:", my_list)
Цей код буде виведено:
The length of the list is: 7
The largest element of the list is: 22
The sum of the elements of the list is: 62
The smallest element of the list is: 1
The updated list after deleting the item with index 3 is: [5, 8, 13, 22, 1, 9]
Похожие вопросы
Предмет: Українська мова,
автор: Katja5689
Предмет: Математика,
автор: yuliavolik30
Предмет: Геометрия,
автор: christina2510
Предмет: Английский язык,
автор: nastaeliseeva150
Предмет: Алгебра,
автор: semenukstas83