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
19 changes: 19 additions & 0 deletions Lesson2/Task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
while True:
operator = input('Выберите операцию (+,-,/,*,) или введите 0 для завершения работы: ')
if operator not in ['0', '+', '-', '/', '*']:
print('Операция не распознана')
if operator == '0':
break
numa = float(input('Введите число a: '))
numb = float(input('Введите число b: '))
if operator == '+':
print(f'Сумма равна {numa+numb}')
if operator == '-':
print(f'Разность равна {numa-numb}')
if operator == '*':
print(f'Результат умножения: {numa*numb}')
if operator == '/':
if 0 != numb:
print(f'Результат деления: {numa/numb}')
else:
print('Не дели на 0!')
Copy link

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 Lesson2/Task3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
number = input('Введите целое число: ')
Copy link

Choose a reason for hiding this comment

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

Верно

nlen = len(number) - 1
while nlen >= 0:
print(number[nlen], end='')
nlen = nlen - 1
8 changes: 8 additions & 0 deletions Lesson2/Task8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
number = input('Введите целое число: ')
Copy link

Choose a reason for hiding this comment

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

Вы упростили задачу. По условию чисел может быть несколько.

count = input('Введите цифру которую необходимо посчитать: ')
counter = 0
for i, c in enumerate(number):
print(c)
if c == count:
counter = counter + 1
print(f'Число заданных цифр в числе: {counter}')
12 changes: 12 additions & 0 deletions Lesson2/task2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
number = input('Введите целое число: ')
oddcnt = nonoddcnt = 0
for i, c in enumerate(number):
check = int(c)
if check % 2 == 0:
Copy link

Choose a reason for hiding this comment

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

Подписывайте на блок-схеме истину и ложь. Иногда можно запутаться )))

oddcnt = oddcnt + 1
else:
nonoddcnt = nonoddcnt + 1
print(f'Число четных цифр: {oddcnt}')
print(f'Число нечетных цифр: {nonoddcnt}')


13 changes: 13 additions & 0 deletions Lesson2/task5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
start = 32
end = 128
symbolsinline = 10
Copy link

Choose a reason for hiding this comment

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

Не забывайте про _, если имя переменной состоит из нескольких слов

i = start
while True:
c = symbolsinline
while c > 0:
print(f'{i} - {chr(i)}', end=' ')
Copy link

Choose a reason for hiding this comment

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

Перепутали фигуры на блок-схеме

i = i + 1
c = c - 1
if i > end:
Copy link

Choose a reason for hiding this comment

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

По условию задачи 128-й символ выводить не нужно.
Кстати, не забывайте в начале файла писать условие задачи.

exit(0)
print()
17 changes: 17 additions & 0 deletions Lesson2/task6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import random

number = random.randint(0, 100)
i = 10
print('Загадано число от 0 до 100. У вас есть 10 попыток чтобы отгадать число')
while i > 0:
answer = int(input('Введите вариант ответа: '))
if answer == number:
print('Вы угадали!')
exit(0)
if answer > number:
Copy link

Choose a reason for hiding this comment

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

elif избавит от лишних проверок.

print('Ваше число больше загаданного')
if answer < number:
print('Ваше число меньше загаданного')
i = i - 1
print(f'Попыток осталось: {i}')
print(f'Вы не угадали! Было загадано число {number}')