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
11 changes: 11 additions & 0 deletions lesson_3/3-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def my_func(arg1, arg2):
try:
result = arg1 / arg2
return result
except ZeroDivisionError:
return "На ноль делить нельзя"


first_num = float(input("Введите первое число: "))
second_num = float(input("Введите второе число: "))
print(my_func(first_num, second_num))

Choose a reason for hiding this comment

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

выполнено

7 changes: 7 additions & 0 deletions lesson_3/3-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def my_func(f_name, f_name2, f_year, f_city, f_email, f_phone):
print(f"Меня зовут {f_name} {f_name2}, я родился в {f_year} году, в городе {f_city}. "
f"Мой эл. адрес {f_email}, телефон {f_phone}")


my_func(f_name="Иван", f_name2="Павлов", f_year="1990",
f_city="Городец", f_email="ivan@mail.ru", f_phone="+7123456789")

Choose a reason for hiding this comment

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

выполнено

5 changes: 5 additions & 0 deletions lesson_3/3-3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def my_func(f_one, f_two, f_three):
print(f_one + f_two + f_three - min(f_one, f_two, f_three))


my_func(70, 50, 80)

Choose a reason for hiding this comment

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

нет решения с ф-цией sort

31 changes: 31 additions & 0 deletions lesson_3/3-4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Оператор **
def my_func(x, y):
if y >= 0:
print("Введите целое отрицательное число. Выход из программы.")
exit()
return x ** y


a = float(input("Основание. Введите число больше нуля: "))
b = int(input("Степень. Введите целое отрицательное число: "))
print(my_func(a, b))


# Цикл while
def my_func(x, y):
y = abs(y)
i = 1
c = int()
while i <= y - 1:
if i > 1:
c = c * x
else:
c = x * x
if i == (y - 1):
return 1 / c
i += 1


a = float(input("Основание. Введите число больше нуля: "))
b = int(input("Степень. Введите целое отрицательное число: "))
print(my_func(a, b))

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_3/3-5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def my_sum():
sum_result = 0
ex = False
while ex == False:
number = input('Введите числа через пробел, для выхода нажмите Q: ').split()
result = 0
for i in range(len(number)):
if number[i] == 'q' or number[i] == 'Q':
ex = True
return sum_result
else:
result = result + int(number[i])
sum_result = sum_result + result
print(f'Сумма чисел равна: {sum_result}')


my_sum()

Choose a reason for hiding this comment

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

выполнено

22 changes: 22 additions & 0 deletions lesson_3/3-6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Первый вариант
def func(a):
return a.title()


print(func("hello world"))


# Второй вариант

def int_func(a):
separate_word = a.split(' ')
total = []
for i in separate_word:
string_element = str(i)
first_letter = string_element[:1].upper()
word = first_letter + string_element[1:]
total.append(word)
return total


print(int_func("hello world"))

Choose a reason for hiding this comment

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

выполнено