-
Notifications
You must be signed in to change notification settings - Fork 0
Lesson_3 #3
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_3 #3
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,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)) | ||
| 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") | ||
|
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,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) | ||
|
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. нет решения с ф-цией sort |
||
| 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)) | ||
|
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 @@ | ||
| 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() | ||
|
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,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")) | ||
|
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.
выполнено