-
Notifications
You must be signed in to change notification settings - Fork 0
Lesson_4 #4
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: main
Are you sure you want to change the base?
Lesson_4 #4
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,13 @@ | ||
| import sys | ||
| from sys import argv | ||
|
|
||
|
|
||
| def z_func(): | ||
| try: | ||
| script_name, h_param, ph_param, b_param = argv | ||
| return (float(h_param) * float(ph_param)) + float(b_param) | ||
| except ValueError: | ||
| return 0 | ||
|
|
||
|
|
||
| print(z_func()) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| src_list = [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55] | ||
| trg_list = [num for i, num in enumerate(src_list[1:]) if num > src_list[i]] | ||
| print(src_list) | ||
| print(trg_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. выполнено |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| print(f'{[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. выполнено |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| 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) < 2] | ||
| print(my_new_list) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 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])}') | ||
|
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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| from itertools import count | ||
|
|
||
| for el in count(int(input('Введите стартовое число: '))): | ||
| print(el) | ||
| if el >= 10: | ||
| break | ||
|
|
||
|
|
||
| from itertools import cycle | ||
|
|
||
| c = 0 | ||
| my_list = [123, False, 'XXX', None] | ||
| for el in cycle(my_list): | ||
| print(el) | ||
| c += 1 | ||
| if c >= 10: | ||
| break | ||
|
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| from itertools import count | ||
| from math import factorial | ||
|
|
||
| def fact(): | ||
| for el in count(1): | ||
| yield factorial(el) | ||
|
|
||
| gen = fact() | ||
| 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 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.
выполнено