Вопрос задан 16.06.2023 в 16:18. Предмет Информатика. Спрашивает Кравчук Максим.

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

подробно)​
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Волинець Марина.

s = list(input())

s[1] = '0'

print(''.join(s))

0 0
Отвечает Есинов Игорь.

k = int(input())

k = k // 100 * 100 + k % 10

print(k)

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

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.

0 0

Похожие вопросы

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

Последние заданные вопросы в категории Информатика

Задать вопрос