-
Notifications
You must be signed in to change notification settings - Fork 73
Add files via upload #122
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: master
Are you sure you want to change the base?
Add files via upload #122
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,114 @@ | ||
"""1. Реализовать функцию, принимающую два числа (позиционные аргументы) и выполняющую их деление. | ||
Числа запрашивать у пользователя, предусмотреть обработку ситуации деления на ноль.""" | ||
|
||
|
||
def delenie(x, y): | ||
if y == 0: | ||
print('Делить на нуль нельзя!') | ||
return | ||
return (x / y) | ||
|
||
|
||
print(delenie(100, 5)) | ||
|
||
"""2. Выполнить функцию, которая принимает несколько параметров, описывающих данные пользователя: | ||
имя, фамилия, год рождения, город проживания, email, телефон. Функция должна принимать параметры | ||
как именованные аргументы. Осуществить вывод данных о пользователе одной строкой.""" | ||
|
||
|
||
def pers_data(f_name, l_name, y_of_bearth, city, pers_email, phone_num): | ||
print(f'Пользователь {f_name} {l_name}, год рождения {y_of_bearth}, проживает в городе {city}, ' | ||
f'адрес электронной почты {pers_email}, номер телефона {phone_num}') | ||
|
||
|
||
pers_data(f_name='Иванов', l_name='Иван', y_of_bearth='1900', city='Чикаго', pers_email="[email protected]", | ||
phone_num='+123455655565') | ||
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. выполнено |
||
|
||
"""3. Реализовать функцию my_func(), которая принимает три позиционных аргумента и возвращает сумму наибольших | ||
двух аргументов.""" | ||
|
||
|
||
def my_func_1(num_a, num_b, num_c): | ||
if num_b > num_a < num_c: | ||
print("Сравниваем первое число") | ||
num_a = 0 | ||
print(f'первое число {num_a}') | ||
elif num_a > num_b < num_c: | ||
print('Сравниваем второе число') | ||
num_b = 0 | ||
print(f'второе число {num_b}') | ||
elif num_a > num_c < num_b: | ||
print('Сравниваем третье число') | ||
num_c = 0 | ||
print(f'третье число {num_c}') | ||
print(num_a + num_b + num_c) | ||
|
||
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. выполнено |
||
|
||
my_func_1(235, 4263, 66) | ||
|
||
"""4. Программа принимает действительное положительное число x и целое отрицательное число y. Выполните | ||
возведение числа x в степень y. Задание реализуйте в виде функции my_func(x, y). При решении задания нужно | ||
обойтись без встроенной функции возведения числа в степень.""" | ||
|
||
|
||
def my_func_2(osnov, step): | ||
result = 1 / osnov | ||
for s in range((-step - 1)): | ||
result = result / osnov | ||
print(result) | ||
|
||
|
||
my_func_2(10, -5) | ||
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. (result) - для чего скобки? |
||
|
||
"""5. Программа запрашивает у пользователя строку чисел, разделённых пробелом. При нажатии Enter должна | ||
выводиться сумма чисел. Пользователь может продолжить ввод чисел, разделённых пробелом и снова нажать Enter. | ||
Сумма вновь введённых чисел будет добавляться к уже подсчитанной сумме. | ||
Но если вместо числа вводится специальный символ, выполнение программы завершается. Если специальный символ | ||
введён после нескольких чисел, то вначале нужно добавить сумму этих чисел к полученной ранее сумме и после | ||
этого завершить программу.""" | ||
|
||
|
||
def string_to_sum(new_array): | ||
new_array = list(new_array.split()) | ||
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. new_array = list(new_array.split()) |
||
global sum_array | ||
sum_array = 0 | ||
global stop_symb | ||
stop_symb = False | ||
for i in range(len(new_array)): | ||
if new_array[i] == '*': | ||
stop_symb = True | ||
break | ||
else: | ||
sum_array = sum_array + int(new_array[i]) | ||
return stop_symb, sum_array | ||
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. global stop_symb |
||
|
||
|
||
stop_symb = False | ||
sum_array = 0 | ||
common_sum = 0 | ||
while stop_symb == False: | ||
string_to_sum(input('Введите числа через пробел. Стоп-символ * : ')) | ||
common_sum = common_sum + sum_array | ||
print(f'Сумма введенных чисел: {(common_sum)}') | ||
|
||
"""6. Реализовать функцию int_func(), принимающую слова из маленьких латинских букв и возвращающую их же, | ||
но с прописной первой буквой. Например, print(int_func(‘text’)) -> Text.""" | ||
|
||
|
||
def str_lower1(lower_case): | ||
print(lower_case.title()) | ||
|
||
|
||
str_lower1('end home start') | ||
|
||
"""7. Продолжить работу над заданием. В программу должна попадать строка из слов, разделённых пробелом. | ||
Каждое слово состоит из латинских букв в нижнем регистре. Нужно сделать вывод исходной строки, но каждое | ||
слово должно начинаться с заглавной буквы. Используйте написанную ранее функцию int_func().""" | ||
|
||
|
||
def str_lower2(*lower_case): | ||
for argum in lower_case: | ||
print(argum.title()) | ||
|
||
|
||
str_lower2('try point well') | ||
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.