-
Notifications
You must be signed in to change notification settings - Fork 445
Таланов И.Д #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Таланов И.Д #292
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,21 +5,70 @@ | |
| # если такой корень вообще можно извлечь | ||
| # Пример: Дано: [2, -5, 8, 9, -25, 25, 4] Результат: [3, 5, 2] | ||
|
|
||
| import math | ||
|
|
||
| a = [2, -5, 8, 9, -25, 25, 4] | ||
| b = [] | ||
|
|
||
| for i in a: | ||
| if i > 0 and math.sqrt(i) % 1 == 0: | ||
| b.append(math.sqrt(i)) | ||
| print(b) | ||
|
|
||
|
|
||
|
|
||
| # Задача-2: Дана дата в формате dd.mm.yyyy, например: 02.11.2013. | ||
| # Ваша задача вывести дату в текстовом виде, например: второе ноября 2013 года. | ||
| # Склонением пренебречь (2000 года, 2010 года) | ||
|
|
||
| day = {'01': "первое", '02': "второе", '03': 'третье', '04': "четвертое", '05': "пятое", '06': "шестое", '07': "седьмое", | ||
| '08': 'восьмое', '09': "девятое", '10': "десятое", '11': "одиннадцатое", '12': "двенадцатое", '13': "тринадцатое", | ||
| '14': "четырнадцатое", '15': "пятнадцатое", '16': "шестнядцатое", '17': "семнадцатое", '18': "восемнадцатое", | ||
| '19': "девятнадцатое", '20': "двадцатое", '21': "двадцать первое", '22': "двадцать второе", '23': "двадцать третье", | ||
| '24': "двадцать четвертое", '25': "двадцать пятое", '26': "двадцать шестое", '27': "двадцать седьмое", | ||
| '28': "двадцать восьмое", '29': "двадцать девятое", '30': "тридцатое", '31': "тридцать первое"} | ||
| month = {"01": "января", "02": "февраля", "03": "марта", "04": "апреля", "05": "мая", "06": "июня", | ||
| "07": "июля", "08": "августа", "09": "сентября", "10": "октября", "11": "ноября", "12": "декабря"} | ||
|
|
||
| date = input('Введите дату в формате dd.mm.yyyy ') | ||
| new_date = date.split('.') | ||
| print('Вы ввели {} {} {}'.format(day[new_date[0]], month[new_date[1]], new_date[2])) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. все верно |
||
|
|
||
| # Задача-3: Напишите алгоритм, заполняющий список произвольными целыми числами | ||
| # в диапазоне от -100 до 100. В списке должно быть n - элементов. | ||
| # Подсказка: | ||
| # для получения случайного числа используйте функцию randint() модуля random | ||
|
|
||
| import random | ||
|
|
||
| lst = [] | ||
| n = random.randint(-100, 100) | ||
| i = -101 | ||
|
|
||
| while i < n: | ||
| lst.append(random.randint(-100, 100)) | ||
| i += 1 | ||
| print(lst) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. отлично |
||
|
|
||
| # Задача-4: Дан список, заполненный произвольными целыми числами. | ||
| # Получите новый список, элементами которого будут: | ||
| # а) неповторяющиеся элементы исходного списка: | ||
| # например, lst = [1, 2, 4, 5, 6, 2, 5, 2], нужно получить lst2 = [1, 2, 4, 5, 6] | ||
| # б) элементы исходного списка, которые не имеют повторений: | ||
| # например, lst = [1 , 2, 4, 5, 6, 2, 5, 2], нужно получить lst2 = [1, 4, 6] | ||
|
|
||
| lst = [1, 2, 4, 5, 6, 2, 5, 2] | ||
| lst2 = [] | ||
| lst3 = [] | ||
|
|
||
| #a | ||
| lst2 = set(lst) | ||
| print(lst2) | ||
|
|
||
| #b | ||
| for i in lst: | ||
| if lst.count(i) == 1: | ||
| lst3.append(i) | ||
| print(lst3) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. и с этим разобрались, вижу множества хорошо изучили |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,10 @@ | |
| # Для решения задачи не используйте встроенные функции и функции из модуля math. | ||
|
|
||
| def my_round(number, ndigits): | ||
| pass | ||
| round_number = 10 ** ndigits | ||
| number_2 = int(number * round_number + 0.5) | ||
| scale_number = number_2 / round_number | ||
| return scale_number | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. хорошо |
||
|
|
||
| print(my_round(2.1234567, 5)) | ||
|
|
@@ -20,9 +23,18 @@ def my_round(number, ndigits): | |
| # !!!P.S.: функция не должна НИЧЕГО print'ить | ||
|
|
||
| def lucky_ticket(ticket_number): | ||
| pass | ||
| lst_1 = list(str(ticket_number)) | ||
| lst_2 = [] | ||
| lst_2.append(lst_1[3:6]) | ||
| del lst_1[3:6] | ||
| lst_1 = [int(i) for i in lst_1] | ||
| lst_2 = [int(el) for el in lst_2] | ||
| if lst_1[0] + lst_1[1] + lst_1[2] == lst_2[0] + lst_2[1] + lst_2[2]: | ||
| print('У вас счастливый билет!') | ||
| else: | ||
| print('У вас обычный билет') | ||
| # Не могу понять в чем ошибка, логика программы вроде бы правильная :( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. отлично. задействовали срезы |
||
|
|
||
|
|
||
| print(lucky_ticket(123006)) | ||
| print(lucky_ticket(12321)) | ||
| print(lucky_ticket(436751)) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,13 +6,26 @@ | |
| # квадратами элементов исходного списка | ||
| # [1, 2, 4, 0] --> [1, 4, 16, 0] | ||
|
|
||
| lst1 = [1, 2, 4, 0] | ||
| lst2 = [el ** 2 for el in lst1] | ||
| print(lst2) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. хорошо |
||
| # Задание-2: | ||
| # Даны два списка фруктов. | ||
| # Получить список фруктов, присутствующих в обоих исходных списках. | ||
|
|
||
| lst1 = ['яблоко', 'груша', 'слива', "вишня", "персик"] | ||
| lst2 = ['ананас', "виноград", "яблоко", "персик", "малина"] | ||
| lst3 = [el for el in lst1 if el in lst2] | ||
| print(lst3) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. отлично |
||
| # Задание-3: | ||
| # Дан список, заполненный произвольными числами. | ||
| # Получить список из элементов исходного, удовлетворяющих следующим условиям: | ||
| # + Элемент кратен 3 | ||
| # + Элемент положительный | ||
| # + Элемент не кратен 4 | ||
|
|
||
| lst = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] | ||
| lst2 = [el for el in lst if not(el % 3) and el > 0 and el % 4] | ||
| print(lst2) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. хорошо |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
хорошо