Skip to content
30 changes: 30 additions & 0 deletions Урок 2. Практическое задание/task_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,33 @@
Вы вместо трехзначного числа ввели строку (((. Исправьтесь
Введите операцию (+, -, *, / или 0 для выхода):
"""

def calc():
operand = input("Введите операцию +, -, *, / \nили 0 для выхода: ")
if operand == '0':
return
if operand not in "+-*/":
print('Нужно ввести +, -, *, / \nили 0 для выхода')
return calc()
try:
num_1 = int(input("Введите первое число: "))
num_2 = int(input("Введите второе число: "))
except ValueError:
return calc()

if operand == '+':
total = num_1 + num_2
elif operand == '-':
total = num_1 - num_2
elif operand == '*':
total = num_1 * num_2
elif operand == '/':
if num_2 != 0:
total = num_1 / num_2
else:
total = 'Undefined'

print(f"Итого: {num_1} {operand} {num_2} = {total}")
return calc()

calc()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

выполнено

18 changes: 18 additions & 0 deletions Урок 2. Практическое задание/task_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,21 @@
Введите число: 123
Количество четных и нечетных цифр в числе равно: (1, 2)
"""
def count_func(numbers, even_count=0, odd_count=0):
if numbers == 0:
return even_count, odd_count
else:
even = numbers % 10
numbers=numbers // 10
if even % 2 == 0:
even_count += 1
else:
odd_count += 1
return count_func(numbers, even_count, odd_count)

try:
number = int(input('Введите набор цифр: '))
except ValueError:
print('Вы ввели НЕ_число, просьба ввести именно число:')
number = int(input('Введите набор цифр: '))
print(f'Количество чисел в вашем числе {number} по пропорции (четные, нечетные): {count_func(number)}')
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

проверьте стиль кода

10 changes: 10 additions & 0 deletions Урок 2. Практическое задание/task_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@
Введите число, которое требуется перевернуть: 123
Перевернутое число: 321
"""


def rev(number,inven=0):
return inven if (number==0) else rev(number//10, inven*10 + number % 10)
try:
user_numb = int(input('Введите число: '))
except ValueError:
print('Вы ввели буквы, а нужно ввести цифры')
user_numb = int(input('Введите число: '))
print(f'В обратном порядке число получаются: {rev(user_numb)}')
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

отрабатывает неверно
Введите число: 1230
В обратном порядке число получаются: 321
плюс ошибки стиля

12 changes: 12 additions & 0 deletions Урок 2. Практическое задание/task_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,15 @@
Решите через рекурсию. Решение через цикл не принимается.
Для оценки Отлично в этом блоке необходимо выполнить 5 заданий из 7
"""

def int_char(num, count, count_end):
if num == 128:
return count_end
else:
if count == 10:
return int_char(num + 1, 1, count_end + f" {num} - {chr(num)}\n")
else:
return int_char(num + 1, count + 1, count_end + f" {num} - {chr(num)}")


print(int_char(33, 1, ""))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

выполнено

30 changes: 30 additions & 0 deletions Урок 2. Практическое задание/task_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,33 @@
Для оценки Отлично в этом блоке необходимо выполнить 5 заданий из 7
Для оценки Отлично в этом блоке необходимо выполнить 5 заданий из 7
"""

from random import randint
print('Нужно угадать число в диапазоне от 1 до 100. У вас будет 10 попыток')

def riddle(numb, count=9):
if count==0:
print(f'ты НЕ_угадал! Верное число {numb}')
return
else:
number = user_numb()
if number==riddle_numb:
print(f'Ты угадал! это цифра {numb}... поздравления!')
return numb
elif number>numb:
print(f'Число {number} БОЛЬШЕ загаданного числа\nУ тебя осталось {count} попыток')
else:
print(f'Число {number} МЕНЬШЕ загаданного числа\nУ тебя осталось {count} попыток')
return riddle(numb, count-1)

def user_numb():
try:
user_numb = int(input('Введите цисло: '))
except ValueError:
print('Нужно ввести число, а не цифру')
user_numb = int(input('Введите цисло: '))
return user_numb

riddle_numb= randint(1,10)

riddle(riddle_numb)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

опять стиль
игнорируете подсказки Пичарма...

2 changes: 2 additions & 0 deletions Урок 3. Практическое задание/task_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
то реализуйте ф-цию-декоратор и пусть она считает время
И примените ее к двум своим функциям.
"""

#заглушка
2 changes: 2 additions & 0 deletions Урок 3. Практическое задание/task_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
Введите пароль еще раз для проверки: 123
Вы ввели правильный пароль
"""

#lesson 3_2 заглушка
2 changes: 2 additions & 0 deletions Урок 3. Практическое задание/task_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
р
а
"""

#lesson 3_3 заглушка
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@

Подсказка: задачу решите обязательно с применением 'соленого' хеширования
Можете условжнить задачу, реализовав ее через ООП
"""
"""

#lesson 3_4 заглушка
29 changes: 29 additions & 0 deletions Урок 5. Практическое задание/task_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,32 @@

Предприятия, с прибылью ниже среднего значения: Копыта
"""
from collections import namedtuple as nt

COMP = nt('Company', ('name period_1 period_2 period_3 period_4'))

comp_num = int(input('Введите число компаний: '))

companies = {}

for i in range(comp_num):
company = COMP(name=input('Введите название компании: '),
period_1=int(input('Введите прибыль за первый квартал: ')),
period_2=int(input('Введите прибыль за второй квартал: ')),
period_3=int(input('Введите прибыль за третий квартал: ')),
period_4=int(input('Введите прибыль за четвертый квартал: ')))
companies[company.name] = (company.period_1 + company.period_2 +
company.period_3 + company.period_4) / 4

aver_prof = 0
for comp_prof in companies.values():
aver_prof += comp_prof
aver_prof /= comp_num

for comp, prof in companies.items():
if prof > aver_prof:
print(f"Прибыль {comp} выше средней по компаниям")
elif prof < aver_prof:
print(f"Прибыль {comp} выше средней по компаниям")
elif prof == aver_prof:
print(f"Прибыль {comp} выше средней по компаниям")
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
Выполните различные операции с каждым из объектов.
Сделайте замеры и оцените, насколько информация в документации
соответствует дейстивтельности.
"""
"""

#Заглушка
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
Поработайте с обычным словарем и OrderedDict.
Выполните различные операции с каждым из объектов и сделайте замеры.
Опишите полученные результаты, сделайте выводы.
"""
"""

#Заглушка