Вопрос задан 16.06.2023 в 14:35. Предмет Другие предметы. Спрашивает Якуцкая Вера.

напишите программу в Python (с помощью while,if,else). С помощью цикла вывести все числа кратные 3

от -30 до 30 включительно. ДАЮ 20 БАЛЛОВ
0 0
Перейти к ответам

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

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

x = -30

y = 30

while x <= y:
x += 1

print(x)

Объяснение:

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

Python Program to Print Multiples of 3

Here's a Python program that uses a while loop, if-else statements to print all numbers that are multiples of 3 from -30 to 30 (inclusive):

```python num = -30 while num <= 30: if num % 3 == 0: print(num) num += 1 ```

This program initializes a variable `num` with -30 and then uses a while loop to iterate through the numbers from -30 to 30. Inside the loop, it uses an if statement to check if the current number is a multiple of 3. If it is, the number is printed. Finally, the `num` is incremented by 1 in each iteration.

This program effectively prints all the numbers that are multiples of 3 within the specified range.

I hope this helps! If you have any further questions or need additional assistance, feel free to ask.

0 0

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

Топ вопросов за вчера в категории Другие предметы

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

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