-
Notifications
You must be signed in to change notification settings - Fork 73
Homework les 4 #129
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?
Homework les 4 #129
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 |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Задание1 | ||
| def sal(): | ||
| try: | ||
| time = float(input('Выработка в часах ')) | ||
| salary = int(input('Ставка в час')) | ||
| bonus = int(input('Премия')) | ||
| res = time * salary + bonus | ||
| print(f'заработная плата сотрудника {res}') | ||
| except ValueError: | ||
| return print('Not a number') | ||
| sal() | ||
|
|
||
| # Задание2 | ||
| my_list = [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55] | ||
| my_new_list = [el for num, el in enumerate(my_list) if my_list[num - 1] < my_list[num]] | ||
| print(f'Исходный список {my_list}') | ||
| print(f'Новый список {my_new_list}') | ||
|
|
||
|
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 | ||
| print(f'Числа от 20 до 240 кратные 20 или 21 - {[el for el in range(20, 241) if el % 20 == 0 or el % 21 == 0]}') | ||
|
|
||
|
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 | ||
| my_list = [2, 2, 2, 7, 23, 1, 44, 44, 3, 2, 10, 7, 4, 11] | ||
| my_new_list = [el for el in my_list if my_list.count(el) == 1] | ||
| print(my_new_list) | ||
|
|
||
|
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. выполнено |
||
| # Задание5 | ||
| from functools import reduce | ||
|
|
||
|
|
||
| def my_func(el_p, el): | ||
| return el_p * el | ||
|
|
||
| print(f'Список четных значений {[el for el in range(99, 1001) if el % 2 == 0]}') | ||
| print(f'Результат перемножения всех элементов списка {reduce(my_func, [el for el in range(99, 1001) if el % 2 == 0])}') | ||
|
|
||
| # Задание6 | ||
| from itertools import count | ||
| from itertools import cycle | ||
|
|
||
| def my_count_func(start_number, stop_number): | ||
| for el in count(start_number): | ||
| if el > stop_number: | ||
| break | ||
| else: | ||
| print(el) | ||
| def my_cycle_func(my_list, iteration): | ||
| i = 0 | ||
| iter = cycle(my_list) | ||
| while i < iteration: | ||
| print(next(iter)) | ||
| i+=1 | ||
| my_count_func(start_number = int(input("enter start number: ")), stop_number = int(input("enter stop number: "))) | ||
| my_cycle_func(my_list = [1, 2], iteration = int(input("enter iteration: "))) | ||
|
|
||
| # Задание7 | ||
| from itertools import count | ||
| from math import factorial | ||
|
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. все импорты должны идти в начале модуля |
||
|
|
||
| def fibo_gen(): | ||
| for el in count(1): | ||
| yield factorial(el) | ||
|
|
||
| gen = fibo_gen() | ||
| x = 0 | ||
| for i in gen: | ||
| if x < 15: | ||
| print(i) | ||
| x += 1 | ||
| else: | ||
| break | ||
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.
не выполнено
Во время выполнения расчёта для конкретных значений необходимо запускать скрипт с параметрами.