
Дано трехзначное число. Замените среднюю цифру на ноль. ввод 123 вывод 103 (на языке python
подробно)

Ответы на вопрос

s = list(input())
s[1] = '0'
print(''.join(s))



k = int(input())
k = k // 100 * 100 + k % 10
print(k)



Replacing the Middle Digit of a Three-Digit Number with Zero in Python
To replace the middle digit of a three-digit number with zero in Python, you can follow these steps:
1. Input the Three-Digit Number - Use the `input()` function to prompt the user to enter a three-digit number. - Convert the input to an integer using the `int()` function.
```python n = int(input("Enter a three-digit number: ")) ```
2. Extract the Digits - Use the modulo operator `%` to extract the individual digits of the number. - Store the digits in a list.
```python x = [n // 100, 0, n % 10] ```
3. Calculate the Result - As the middle digit is replaced with zero, the new number can be obtained by multiplying the hundreds digit by 100 and adding the units digit.
```python result = x[0] * 100 + x[2] ```
4. Print the Result - Use the `print()` function to display the resulting number.
```python print("The number after replacing the middle digit with zero is:", result) ```
Example
If the input is 123, the output will be 103.This Python code allows you to replace the middle digit of a three-digit number with zero and obtain the resulting number.


Похожие вопросы
Топ вопросов за вчера в категории Информатика







Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili