
9. Составьте программы в Python. 1) Найдите произведение цифр четырехзначного числа. 2) Найдите
сумму второй, третьей и четвертой цифр пятизначного числа

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

1) a = int(input())
b = a % 10
c = a % 100 // 10
d = a // 100 % 10
e = a // 1000
print(b * c * d * e)
2) a = int(input())
b = a % 100 // 10
c = a // 100 % 10
d = a // 1000 % 10
print(b + c + d)



I can help you with writing Python programs. Here are some possible solutions for your tasks:
1) To find the product of the digits of a four-digit number, you can use the following code:
```python # Input a four-digit number as a string number = input("Enter a four-digit number: ")
# Initialize the product as 1 product = 1
# Loop through each digit and multiply it with the product for digit in number: product = product * int(digit)
# Print the product print("The product of the digits is", product) ```
2) To find the sum of the second, third and fourth digits of a five-digit number, you can use the following code:
```python # Input a five-digit number as a string number = input("Enter a five-digit number: ")
# Extract the second, third and fourth digits using slicing digits = number[1:4]
# Initialize the sum as 0 sum = 0
# Loop through each digit and add it to the sum for digit in digits: sum = sum + int(digit)
# Print the sum print("The sum of the second, third and fourth digits is", sum) ```
I hope this helps. If you have any other questions, feel free to ask me.


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


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








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