Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lesson_4/4-1.py
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())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено

4 changes: 4 additions & 0 deletions lesson_4/4-2.py
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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено

1 change: 1 addition & 0 deletions lesson_4/4-3.py
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]}')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено

3 changes: 3 additions & 0 deletions lesson_4/4-4.py
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)
9 changes: 9 additions & 0 deletions lesson_4/4-5.py
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])}')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено

17 changes: 17 additions & 0 deletions lesson_4/4-6.py
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено

15 changes: 15 additions & 0 deletions lesson_4/4-7.py
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено