In the last lesson we studied the
cycle with the precondition FOR. Today we will solve problems with the FOR
loop.
In the FOR loop, you can specify
the exact number of repetitions that the programmer needs. Let's look at an example of a FOR
loop:
//На прошлом уроке мы изучили
цикл с предусловием FOR. Сегодня
мы будем решать задачи с циклом FOR.
В цикле FOR можно указать
точное количество повторений, нужное программисту
At the beginning we’ll remember (rewise) the Python
program structure. Let’s rewise it together. //Для начала мы вспомним структуру программы на языке
Паскаль.
Оқушылар тест орындайды.(Quizizz программасы)
- Here are our results// Вот такие у нас результаты
And now// ал, енді
Solve the
following activity in pairs.
1. Eldar
uses a controller with a circuit to light 16 LED lamps which are labeled from
1 to 16. When the controller a gives signal to a LED lamp, it changes its
state (ON or OFF). In the beginning, all the LEDs are switched OFF. Eldar has
found a sequence of lightning: On the 1st second controller lights ON all LED
lamps. (1….2….3….) On the 2nd it lights ON the LEDs that are even in the
circuit. (2...4...6….) On 3rd second it lights every third LED in the
circuit. (3...6...9…) And so it continues in similar way... Which LEDs must
be switched ON after the 16th second?
2. 100
tenge There are (N) number of coins on table. Some of them are tails, and
some are heads. How many coins do we need to turn around so that all coins be
of the same side? We have total number of coins (N). Next N rows contain the
numbers 1 (if a coin is up tail) or 0 (if a coin is up head). Find the
minimum number of coins that you must turn. Input: The first line is a total
number of coins, next lines are values of tails or head. tails = 1, head = 0 Output:
Minimum number of coins that we must turn.
We decide together //Решаем вместе
Resolution
n=int(input())
for i in range (n):
x=int(input())
if x==0:
s=s+1
print(s)
Writing in a
notebook:
1. The solution of the problem
2. Terminology
divisor - бөлгіш - делитель
controller - тексеруші – контролер
head
- тиынның сыртқы беті - орел
circuit - тізбек - цепь
independence - тәуелсіздік -
независимость ascending - өсу - восходящий
ancestor - арғы ата - предок
particularly - атап айтқанда - в
частности
LED
- жарық диодты индикатор - светодиод independent - тәуелсіз -
независимый
|
|
Оставьте свой комментарий
Авторизуйтесь, чтобы задавать вопросы.