Вопрос задан 11.11.2026 в 21:29. Предмет Информатика. Спрашивает Пернебек Айбек.

4. Write a Python program to get the smallest number from a list.
5. Write a Python program to count the number of strings where the string length is 2 or more and the first and last character are the same from a given list of strings.
6. Write a Python program to remove duplicates from a list.
7. Write a Python program to check if a list is empty or not.
8. Write a Python program to clone or copy a list.
9. Write a Python program to find the list of words that are longer than n from a given list of words.
10. Write a Python program that takes two lists and returns True if they have at least one common member.

Перейти к ответам

Ответы на вопрос

Отвечает Поплавская Вера.

4. Smallest number in a list
numbers = [12, 5, 8, 1, 9]
print(min(numbers))

5. Count strings with the same first and last character
words = ['aba', 'abc', 'aa', 'b', 'hello']
count = sum(1 for word in words if len(word) >= 2 and word[0] == word[-1])
print(count)

6. Remove duplicates from a list
numbers = [1, 2, 2, 3, 1, 4]
unique_numbers = []
for number in numbers:
    if number not in unique_numbers:
        unique_numbers.append(number)
print(unique_numbers)

7. Check whether a list is empty
items = []
if not items:
    print('The list is empty')
else:
    print('The list is not empty')

8. Copy a list
original = [1, 2, 3]
copy_list = original[:]
print(copy_list)

9. Words longer than n
words = ['cat', 'elephant', 'book', 'computer']
n = 4
result = [word for word in words if len(word) > n]
print(result)

10. Check for a common member in two lists
list1 = [1, 2, 3]
list2 = [3, 4, 5]
print(bool(set(list1) & set(list2)))

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос