Skip to content
Open
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
71 changes: 71 additions & 0 deletions HW4.py
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()

Choose a reason for hiding this comment

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

не выполнено
Во время выполнения расчёта для конкретных значений необходимо запускать скрипт с параметрами.


# Задание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}')

Choose a reason for hiding this comment

The 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]}')

Choose a reason for hiding this comment

The 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)

Choose a reason for hiding this comment

The 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

Choose a reason for hiding this comment

The 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