diff --git a/task1.py b/task1.py new file mode 100644 index 0000000..235d4cd --- /dev/null +++ b/task1.py @@ -0,0 +1,9 @@ +def division(num1, num2): + if num2 == 0: + return 'Division by zero!' + return num1 / num2 + + +num1 = int(input('Введите первое число: ')) +num2 = int(input('Введите второе число: ')) +print(division(num1, num2)) diff --git a/task2.py b/task2.py new file mode 100644 index 0000000..92104a6 --- /dev/null +++ b/task2.py @@ -0,0 +1,11 @@ +def user( + name='Имя', + surname='Фамилия', + birth_year='1990', + city='Москва', + email='test@test.ru', + phone='8 (999) 999 99-99'): + return f"{surname} {name}, {birth_year} года рождения, город {city}, E-mail: {email}, Телефон: {phone}" + + +print(user('Игорь', 'Назаров')) diff --git a/task3.py b/task3.py new file mode 100644 index 0000000..28a0dc6 --- /dev/null +++ b/task3.py @@ -0,0 +1,8 @@ +def my_func(x, y, z): + array = [x, y, z] + array.sort(reverse=True) + return array[0] + array[1] + + +res = my_func(11, 2, 4) +print(res) diff --git a/task4.py b/task4.py new file mode 100644 index 0000000..fb284a4 --- /dev/null +++ b/task4.py @@ -0,0 +1,14 @@ +def my_func(x, y): + if not isinstance(y, int) or y >= 0: + return 'Ошибка, введите целое отрицательное число' + ci = abs(y) + i = 0 + result = 1 + while i < ci: + result *= 1 / x + i += 1 + return result + # Ну или просто x ** y :) + + +print(my_func(400, -1)) diff --git a/task5.py b/task5.py new file mode 100644 index 0000000..efebd5c --- /dev/null +++ b/task5.py @@ -0,0 +1,18 @@ +total = 0 + + +def sum_my_numbers(num_str, t): + numbers = num_str.split(' ') + for num in numbers: + if num == 'stop': + return t, True + t += int(num) + return t, False + + +while True: + numbers_str = input('Введите числа через пробел (чтобы остановиться, введите stop): ') + total, stop = sum_my_numbers(numbers_str, total) + print(total) + if stop: + break diff --git a/task6.py b/task6.py new file mode 100644 index 0000000..71cfde4 --- /dev/null +++ b/task6.py @@ -0,0 +1,15 @@ +def int_func(word): + return word.capitalize() + + +words = input('Введите слова через пробел: ') +words_split = words.split(' ') +title_words = [] +for w in words_split: + title_word = int_func(w) + title_words.append(title_word) + + +print(' '.join(title_words)) +# Либо еще проще +print(words.title())