Предмет: Информатика, автор: ushakovy

Задача 1: Знайти добуток цілих непарних чисел другого десятка (від 11 до 20).
Задача 2: Знайти суму цілих додатних чисел, кратних 9 на інтервалі від -10 до 30.

Ответы

Автор ответа: vimmortal2
2

Програма:

Python:

№1)

def odd_product(start, end):

   product = 1

   for i in range(start, end+1):

       if i % 2 != 0:

           product *= i

   return product

print("Добутком непарних чисел від 11 до 20:", odd_product(11, 20))

№2)

def sum_numbers(start, end):

   total = 0

   for i in range(start, end+1):

       if i > 0 and i % 9 == 0:

           total += i

   return total

print("Сума додатних кратних 9 від -10 до 30:", sum_numbers(-10, 30))

Пояснення:

№1)

Цей код визначає функцію odd_product, яка приймає початковий і кінцевий діапазон як вхідні дані, а потім обчислює добуток непарних чисел у цьому діапазоні. Добуток обчислюється циклом по діапазону чисел, перевіряючи, чи кожне число непарне (не ділиться на 2), і якщо це так, множенням його на змінну добутку, яка починається з 1. Результат обчислення повертається за допомогою функцію та друкується в консолі.

№2)

Цей код визначає функцію sum_numbers, яка приймає початковий і кінцевий діапазон як вхідні дані, а потім обчислює суму додатних цілих чисел, кратних 9 у цьому діапазоні. Сума обчислюється циклом по діапазону чисел, перевіряючи, чи кожне число додатне та кратне 9 (ділиться на 9 без залишку), і якщо так, додаючи його до загальної змінної, яка починається з 0. Результат обчислення повертається функцією та друкується в консолі.


ushakovy: Спасибо брат выручил
Похожие вопросы
Предмет: Английский язык, автор: dias8427
READING
Task 1. Read the text carefully and answer the questions.
ANXIOUS ABOUT MATH?
YOUR BRAIN MAY TACKLE SIMPLE PROBLEMS DIFFERENTLY
Some people get jittery when faced with simple math problems. And they may rely more heavily on
certain brain circuits than do people who do not experience such math anxiety. That's the finding of a new
study. Using a different mental approach might help explain why people with math anxiety struggle more with
complex problems.
To figure out what was going on, researchers placed adults in a brain-scanning device. Called a
functional magnetic resonance imaging machine, it measures blood flow in the brain. This lets researchers see
which brain regions are active at a particular point in time. For the new study, the study recruited people with
and without math anxiety. All of the adults were asked to answer whether simple math problems - such as
9+2-11-were correct or not. Both groups had similar response times. Each group also was equally accurate.
The brain scans, however, turned up some differences.
In people who weren't anxious about math, there was less activity in one brain region. It is called the
frontoparietal (FRUN-tow-pah-RY-ch-tul) attention network. It is involved in working memory and the solving
of problems. Less activity here was linked to performing better. But not in math-anxious people. Those adults
showed no link between performance and the level of activity in this network.
People who relied on this circuit less were probably getting ahead by automating simple math. said
Hyesang Chang. She's a cognitive neuroscientist who works at the University of Chicago in Illinois. She
reported her team's findings March 25 here at the annual meeting of the Cognitive Neuroscience Society.
People who get anxious over math showed more varied brain activity overall. That led Chang to
speculate that these people might be tackling math in a different way. Their brains might be using a variety of
approaches and in ways that use more brain resources. This scattershot approach works fine for simple math.
she said. But the brains of those with math anxiety might get maxed out when the math is more challenging.
B)
C)
1. What happened with some people when faced with simple math problems?
A)
they are get jittery
they are get happy
they are crying
2. What measure a brain-scanning device?
A)
memory flow in the brain
B)
C)
brain volume
blood flow in the brain
Предмет: Русский язык, автор: bacurinaana23