-
Notifications
You must be signed in to change notification settings - Fork 0
Homework Lesson2 #2
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: lesson1b
Are you sure you want to change the base?
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,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!') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| number = input('Введите целое число: ') | ||
|
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. Верно |
||
| nlen = len(number) - 1 | ||
| while nlen >= 0: | ||
| print(number[nlen], end='') | ||
| nlen = nlen - 1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| number = input('Введите целое число: ') | ||
|
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. Вы упростили задачу. По условию чисел может быть несколько. |
||
| count = input('Введите цифру которую необходимо посчитать: ') | ||
| counter = 0 | ||
| for i, c in enumerate(number): | ||
| print(c) | ||
| if c == count: | ||
| counter = counter + 1 | ||
| print(f'Число заданных цифр в числе: {counter}') | ||
| 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: | ||
|
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. Подписывайте на блок-схеме истину и ложь. Иногда можно запутаться ))) |
||
| oddcnt = oddcnt + 1 | ||
| else: | ||
| nonoddcnt = nonoddcnt + 1 | ||
| print(f'Число четных цифр: {oddcnt}') | ||
| print(f'Число нечетных цифр: {nonoddcnt}') | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| start = 32 | ||
| end = 128 | ||
| symbolsinline = 10 | ||
|
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. Не забывайте про |
||
| i = start | ||
| while True: | ||
| c = symbolsinline | ||
| while c > 0: | ||
| print(f'{i} - {chr(i)}', end=' ') | ||
|
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. Перепутали фигуры на блок-схеме |
||
| i = i + 1 | ||
| c = c - 1 | ||
| if i > end: | ||
|
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. По условию задачи 128-й символ выводить не нужно. |
||
| exit(0) | ||
| print() | ||
| 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: | ||
|
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. elif избавит от лишних проверок. |
||
| print('Ваше число больше загаданного') | ||
| if answer < number: | ||
| print('Ваше число меньше загаданного') | ||
| i = i - 1 | ||
| print(f'Попыток осталось: {i}') | ||
| print(f'Вы не угадали! Было загадано число {number}') | ||
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.
Потеряли стрелочку в блок-схеме