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

СРОЧНО!! ДАЮ 50 БАЛЛОВ!!!
Язык программиривания - Python
Количество различных элементов — 2
Дан список. Посчитайте, сколько в нём различных элементов, не изменяя самого списка.

Входные данные

Вводится список чисел. Все числа списка находятся на одной строке. Все числа целые неотрицательные и не больше 1000.

Выходные данные

Выведите ответ на задачу.

Примеры
Ввод

3 2 1 2 3

1 2 3 4 5

Вывод

3

5

И еще одна:
Самое частое число
Дан список. Не изменяя его и не используя дополнительные списки, определите, какое число в этом списке встречается чаще всего.

Если таких чисел несколько, выведите любое из них.

Входные данные

Вводится список чисел. Все числа списка целые, по модулю не превосходят 1000 и находятся на одной строке.

Выходные данные

Выведите ответ на задачу.

Примеры
Ввод

1 1 1 1 2 2 2 3 3 3

Вывод

1


zlodeika225: В интернете можете не искать, там нет решений.

Ответы

Автор ответа: KnowsUser1
22

Ответ:

#1

lst = [int(i) for i in input().split()]

print(len(set(lst)))  

#2

import statistics  

lst = [int(i) for i in input().split()]

print(statistics.mode(lst))

Объяснение:

#1

set() не изменяет состояния списка, передаваемого аргументом. Возвращает объект типа set, представляющий собой множество уникальных объектов, входивших в изначальный список. Длина этого множества и есть кол-во уникальных элементов в изначальном списке

#2

Модуль statistics является встроенным модулем Python (предоставляется пользователю "из коробки", без нужды качать что либо), и предоставляет набор функций и классов для работы со статистикой. Функция statistics.mode([iterable]) возвращает самый часто встречающийся элемент переданного ей списка (или любого другого итерируемого объекта)


zlodeika225: Спасибо! В моем профиле есть ещё вопросы по Python с награждением в 30 или 40 баллов.
Похожие вопросы
Предмет: Английский язык, автор: нас97
.помогите с переводом, нужен нормальный, разговорный, пожалуйста!!!
1. Teenagers today have a lot more to worry about than their parents ever did. The world is becoming a very scary place. Violence, teen pregnancy, and AIDS cases are increasing. More and more teens are turning to drugs and alcohol. I'm sure that almost every teenager will at one time or another have an experience with drugs, alcohol or sex. These things combined with personal problems and mates' influence make being a teenager very difficult. I don't have a single friend who has never had a drink of alcohol. Some of them don't drink at all now, but some do. It seems to me that adults are generally quite indifferent to what their children do. Once you reach the age of sixteen or seventeen, your parents think you are old enough to decide for yourself and let you do what you want.

2. It's true that there are so many problems facing
teens today. I go to an all-girls private
school which makes my school life easier. I focus more attention on
doing my work than on impressing a cute
guy. But when I go out on weekends there is a lot of pressure to drink
and smoke. There are no teen clubs close to
where I live so weekend activities are limited. My friends and I don't
do anything exciting, but we usually have
fun just being around each other. We usually talk v about
humorous things. On the other hand, we also talk about serious things like
abortion, sex, and politics. My friends and I try to help each other if we can,
because a lot of the time, being a teenager isn't fun. It's a chore (duty). You
have to go to school and your parents want you to get good grades, which are
hard enough in itself, and you have to deal with your own problems too.

 3. Where I live
teenagers have few dangers, but even in my town kids can get alcohol easily. I
personally do not drink alcohol. I don't think drinking is exciting. But I know
some guys who do. My view is that if they want to, then they can-it's their
life, they are free to decide and nobody can forbid them to do what they want.

The
people I hang about with don't really put any
pressure on me or anyone else.


Dating is not a big
deal .We usually go out with a bunch of friends, both girls and boys.

Social events such as discos
and parties are a very popular conversation topic among teenagers. At school,
politics are discussed quite a lot but along with this there are conversations
about boyfriends, girlfriends, and plans for the weekend ahead. I feel also
that the majority of boys are football-mad and the girls are very conscious of their appearance and clothes. Being
a teenager is great fun. Take
it easy.

Предмет: Литература, автор: настенчиклимончик2
Предмет: Литература, автор: polinashalamov