background top icon
background center wave icon
background filled rhombus icon
background two lines icon
background stroke rhombus icon

Download "Уроки Python для начинающих | #6 - Циклы For, While, а также операторы"

input logo icon
Video tags
|

Video tags

циклы python
python for
python while
python break
python while loop
python
уроки python
python программирование
python для начинающих
python обучение
python 3
python programming
python уроки программирования
python уроки для начинающих
питон
пайтон
питон уроки
уроки пайтон
#GoshaPython
Subtitles
|

Subtitles

subtitles menu arrow
  • ruRussian
Download
00:00:00
I welcome you to a new video lesson in
00:00:01
which we will study cycles and also
00:00:04
operators for cycles. Visit the website
00:00:07
itproger.com. The link to this video lesson
00:00:10
on the site will be in the description of the video. Here
00:00:11
you will find both the code and homework for
00:00:13
each video lesson, thanks to the cycle we
00:00:16
can perform what - code several
00:00:19
times, and the number of times we
00:00:21
can indicate first, let’s
00:00:23
study a loop like while first
00:00:26
of all, we need to write a variable.
00:00:28
Well, for example, the usual way
00:00:30
in loops is to write the variable name as I
00:00:33
Well, it’s already just accepted, let’s
00:00:36
call the variable I and assign it
00:00:38
the value zero, then we write
00:00:40
just this loop of ours while in which we
00:00:42
must set a
00:00:44
condition, remember in the last lesson we
00:00:47
already went through conditional statements and
00:00:49
there we essentially already
00:00:50
figured it out a little, that is what conditions are there
00:00:52
more less equals And so on The
00:00:54
same thing is here for now Well, that is,
00:00:56
while - this is exactly translated While yes,
00:00:59
that is As long as our I is less than 10
00:01:02
We will execute some piece of
00:01:04
code, that is, here essentially the same
00:01:06
as in conditional operators, some
00:01:07
keyword condition and then a colon,
00:01:11
that is, nothing new at all, essentially, that’s
00:01:13
what we’re doing here, let’s just
00:01:16
display ours on the screen. This one here
00:01:18
I, that is, 1 2 3 4 5 6 but this loop
00:01:22
At the moment it will be infinite
00:01:24
Why Because each time the loop will
00:01:26
go through and each time it will be our I
00:01:30
will be equal to zero, respectively, each
00:01:32
time it will just be well, it will
00:01:35
fit the condition that it is less than
00:01:36
ten and accordingly this I will be
00:01:38
displayed infinitely so we here Let's
00:01:40
add that our I will be equal to PD
00:01:44
for example, that is, in one iteration it
00:01:46
will add P2 Well, you can plus o For
00:01:48
example, you can do the same with
00:01:50
multiplication, for example, we will multiply by
00:01:52
two, but here it will be stupid because we are
00:01:54
not multiplying by 2, that is, accordingly
00:01:56
again -it’s an infinite loop, so we’ll
00:01:58
just write the following condition: That in one
00:02:01
iteration, that is, in one circle, our I
00:02:04
will be added to our I,
00:02:06
P2 will be added, respectively,
00:02:08
this loop will be output only five times, let’s
00:02:11
try to run it all and we
00:02:13
see that it’s output like five times
00:02:15
it happened, but then 2 4 6 8 Well, that is,
00:02:18
accordingly, initially zero Then 2
00:02:20
well plus d plus plus two more plus d and
00:02:23
so on until it became equal children
00:02:26
if I wrote here for example that
00:02:28
less is equal to 10 then y we will get this
00:02:31
cycle six times, respectively, plus
00:02:33
another ten, for example, and again
00:02:35
the same thing. I can here, as I already
00:02:37
said, not a plus, for example, but let's
00:02:40
do this until it is no less and
00:02:42
until it is more than a hundred. And for example, here
00:02:45
here we’ll just put it, well,
00:02:48
initially, like this, we’ll put it
00:02:50
equal to 1.000 A And we’ll divide it by
00:02:52
two, each time we’ll divide it by 2
00:02:54
Accordingly, what we’ll get is that we’ll get
00:02:57
1.000 initially, then 500 200
00:02:59
50 125 And then o it’s no longer it fits the
00:03:02
condition, it will already be less than a hundred,
00:03:06
so it didn’t fit the condition, that is,
00:03:07
here I think everything is clear to you, we display a
00:03:09
piece of code several times Well,
00:03:13
accordingly, plus the conditions we ourselves
00:03:14
can fill in as we like, that is, this is
00:03:17
more than zero this is less than zero Well or rather,
00:03:19
more than some more than any number is
00:03:21
equal to something, for example, there is
00:03:23
some variable Well, and so on, yes, that is,
00:03:25
everything here is basically clear. I
00:03:27
think now cycle 4 cycle 4 is a little
00:03:31
more complicated, but nevertheless it has
00:03:33
key properties that
00:03:36
allow it to be traversed not just by
00:03:37
some condition, for example like here,
00:03:39
if something is greater than this or equal to
00:03:42
that and We then execute a loop, it is a
00:03:45
cycle 4. It allows you to traverse a
00:03:47
string or a list. Well, what
00:03:50
is a string? I think you already know everything, yes, that
00:03:52
is, just a string. And we
00:03:54
will study lists a little later with you.
00:03:56
Those who have studied programming
00:03:58
already understand what I’m talking about. Well, if
00:04:00
not, then in the next lessons we will study it
00:04:03
with you. So I have already
00:04:05
prepared a small code And what is happening here in
00:04:07
it You can rewrite it
00:04:09
or just basically listen to it Firstly, we
00:04:12
have the keyword for Then
00:04:14
we have a certain variable and the
00:04:16
keyword in, that is, where we
00:04:19
will be able to check all this Or what Or
00:04:21
or how to process that is at the
00:04:24
moment since we haven’t studied lists yet
00:04:26
So I took a regular string Well, the
00:04:28
string is like a string, that is, here it’s
00:04:30
just the word Hello world What’s
00:04:33
going on here We get a string - it’s
00:04:36
like MASI it’s like a separate one set for
00:04:39
each letter yes, that is, for example H and l o
00:04:43
and so on Yes, so we each
00:04:45
take this letter here, multiply it by two,
00:04:48
so it will be displayed, for example, hh and and
00:04:52
ll Well, and then again l then oo Well, and
00:04:55
so on, yes that is, like twice
00:04:57
and at the end I added this little thing
00:04:59
that it means, it means that we won’t
00:05:01
go to a new line every time after Print
00:05:04
because that’s
00:05:06
actually Well in this case at the moment
00:05:08
it wouldn’t be It’s absolutely beautiful, well, for
00:05:10
example, Let’s run it and see what
00:05:12
comes out of it. It turned out well. Well,
00:05:14
firstly, this was revealed from the last cycle.
00:05:16
And here, as you can see, it was displayed twice,
00:05:19
that is, and and then again l oo two
00:05:23
spaces, and so on And so on
00:05:25
thanks to this N that I wrote here,
00:05:27
it’s all in one line, if I delete this
00:05:29
end, then we will notice that we have
00:05:32
everything revealed in this way, that is,
00:05:34
twice But each time Then From a new
00:05:35
line, accordingly, you can multiply by three
00:05:37
Well, so on Well, this is
00:05:38
purely just a game, here the essence is What is what I
00:05:41
want to show you Well, on three you see, that
00:05:43
is, three letters each displays the essence What is
00:05:45
that for It allows you to go through
00:05:47
any
00:05:48
array again, in the future we will
00:05:51
study them either by
00:05:53
line the Wi loop cannot do this, but
00:05:56
it is wonderful, wonderful
00:05:59
in its checks, for example, like this
00:06:01
check in for, we
00:06:03
can’t do this anymore Well, accordingly, each has
00:06:05
its own pros and cons, now let’s
00:06:07
look at the operators that are
00:06:09
used in loops, we will
00:06:11
consider these operators for the for loop,
00:06:13
but they will work exactly the same way and
00:06:16
they are written exactly the same way for the
00:06:19
while loop. Therefore, if anything, you can
00:06:21
use them in the while loop. Well, I
00:06:22
’ll just show them in the for loop. Well, that
00:06:24
is, this is so, first of all, let’s
00:06:27
do it. use some kind of check If J
00:06:30
pa W That is, if this is ours, if we
00:06:33
have reached the letter W, then we will just
00:06:36
use an operator like continue,
00:06:39
what does it do? Well, let’s start with all this, let’s start
00:06:41
the case, that is,
00:06:44
Oops Clear Let’s start this case and what he
00:06:48
did, look, we display
00:06:51
absolutely everything, essentially the same,
00:06:53
only the letter W As you can see, it’s
00:06:56
simply skipped here You see, it’s here,
00:06:58
and here it is, that is, the
00:07:00
contin operator, it skips one iteration, for
00:07:03
example, We’ve reached it, We’ve reached it, we
00:07:05
checked it the condition is that we have J equal to
00:07:07
w and accordingly he simply skipped
00:07:10
this iteration, skipped this circle and
00:07:12
spread to the next well on to the
00:07:15
next iteration in the next iteration,
00:07:17
again it was the same thing that
00:07:19
J early W he again missed and since
00:07:22
we are multiplying by three then also in the third
00:07:23
operation the same thing was that it was
00:07:26
equal to W, he missed it again and then
00:07:28
every time he checked this condition was not
00:07:32
true and accordingly everything was output
00:07:35
exactly the same. If for example I write not
00:07:37
equal to W then we will only get
00:07:39
exactly W you see T W came out and all the
00:07:42
other letters were skipped,
00:07:44
simply now the next operator is the
00:07:46
Bray operator, what does it do, first of all,
00:07:49
here let’s put it exactly
00:07:50
equal to W So let’s run it all again
00:07:54
here, I’ll clear it all up a little and once again
00:07:56
Now let’s run what it outputs, look at
00:07:59
our Hello word and then three spaces.
00:08:02
And then, in general, you can simply say that it
00:08:04
exited the loop, and it actually
00:08:07
exited the loop, that is, it makes a break. It’s not that
00:08:09
it skips any iteration,
00:08:11
but it exits the loop altogether
00:08:13
accordingly, as soon as it reached the
00:08:16
letter W, we checked the condition, it is equal to w
00:08:20
and it simply exited the loop. That is, we can
00:08:22
say that the compiler, after
00:08:25
we reached W, ended up here, there is
00:08:27
no code here, which means the program was
00:08:29
completed, this is how continue and work work.
00:08:33
this is how Break works. In addition,
00:08:34
there is a third operator
00:08:37
called els and it works in exactly the same way
00:08:40
for both while and for, so
00:08:42
again, I’ll just use it for for.
00:08:44
But remember that for la it
00:08:46
will work the same way.
00:08:48
It is after the cycle after the cycle itself, and
00:08:51
on the same line with this cycle, as you can see, that
00:08:52
is, there are no such
00:08:54
indentations here, you don’t need to do it on the
00:08:56
same line, but for Wi it’s the same
00:08:59
here it would be written down.
00:09:01
Accordingly, what does it do if in
00:09:03
our cycle there is generally a Break and
00:09:06
this break has never worked during the entire cycle,
00:09:08
then our else will be executed,
00:09:11
that is, look, let me
00:09:13
write here in this way. But firstly,
00:09:16
here I will write that we are checking for the
00:09:18
presence of the letter a which is here there is no here,
00:09:22
let's multiply by two Well, so
00:09:24
that there are fewer of these letters And
00:09:26
here I will write that the letters and there are no in in the
00:09:32
word So, accordingly, let me
00:09:35
try to run it all and see
00:09:37
what comes out of it As you can see, it
00:09:40
worked, it came out this is all our
00:09:42
break didn’t work in the loop and therefore the
00:09:45
els operator worked, which just
00:09:47
showed that the letters and are not in the word, well, for
00:09:50
example, it would probably even be
00:09:52
more convenient if we didn’t display anything
00:09:54
on the screen, so I’ll delete it Print
00:09:56
That’s accordingly if Let’s also since
00:09:58
I'm for sch just to see it all Yes,
00:10:01
letters and no conditions Here, accordingly,
00:10:03
if I had written here, for example, W, our
00:10:06
Bray would have worked because W is in
00:10:09
this word and our Es no longer worked,
00:10:12
respectively, nothing came out of
00:10:14
this cycle at all Yes, els didn’t work
00:10:16
Break worked Well, in general, this is the
00:10:19
little thing, that is, again, all the
00:10:21
operators act both with for and with wi, the
00:10:24
loops themselves, as I think, you already understand what
00:10:26
they do, they process Well, either for
00:10:28
are lists either or
00:10:29
process the lines directly with a bang while this
00:10:32
executes the command several times According to
00:10:34
some condition, that is, this is
00:10:36
how to work with loops in the Python language,
00:10:39
that’s all Subscribe, join the
00:10:41
VKontakte group, go to the site
00:10:42
itproger.com All links will be in the description see
00:10:45
you soon bye

Description:

Урок на сайте itProger: https://itproger.com/course/python/6 В этом уроке мы с вами изучим циклы в языке Python. Благодаря циклам мы можем проделывать операции несколько раз всего за пару строк кода. Мы изучим циклы For, While, а также операторы continue, break и else. ✔ Основной сайт: https://itproger.com/ ✔ ------------- Вступай в группу Вк - https://vk.com/prog_life Группа FaceBook - https://www.facebook.com/unsupportedbrowser Instagram: https://www.facebook.com/unsupportedbrowser Telegram: https://t.me/itProger_official Страничка Twitter - https://twitter.com/GoshaDudar - Уроки от #GoshaDudar 👨🏼‍💻 - Все уроки по хештегу #GoshaPython

Preparing download options

popular icon
Popular
hd icon
HD video
audio icon
Only sound
total icon
All
* — If the video is playing in a new tab, go to it, then right-click on the video and select "Save video as..."
** — Link intended for online playback in specialized players

Questions about downloading video

mobile menu iconHow can I download "Уроки Python для начинающих | #6 - Циклы For, While, а также операторы" video?mobile menu icon

  • http://unidownloader.com/ website is the best way to download a video or a separate audio track if you want to do without installing programs and extensions.

  • The UDL Helper extension is a convenient button that is seamlessly integrated into YouTube, Instagram and OK.ru sites for fast content download.

  • UDL Client program (for Windows) is the most powerful solution that supports more than 900 websites, social networks and video hosting sites, as well as any video quality that is available in the source.

  • UDL Lite is a really convenient way to access a website from your mobile device. With its help, you can easily download videos directly to your smartphone.

mobile menu iconWhich format of "Уроки Python для начинающих | #6 - Циклы For, While, а также операторы" video should I choose?mobile menu icon

  • The best quality formats are FullHD (1080p), 2K (1440p), 4K (2160p) and 8K (4320p). The higher the resolution of your screen, the higher the video quality should be. However, there are other factors to consider: download speed, amount of free space, and device performance during playback.

mobile menu iconWhy does my computer freeze when loading a "Уроки Python для начинающих | #6 - Циклы For, While, а также операторы" video?mobile menu icon

  • The browser/computer should not freeze completely! If this happens, please report it with a link to the video. Sometimes videos cannot be downloaded directly in a suitable format, so we have added the ability to convert the file to the desired format. In some cases, this process may actively use computer resources.

mobile menu iconHow can I download "Уроки Python для начинающих | #6 - Циклы For, While, а также операторы" video to my phone?mobile menu icon

  • You can download a video to your smartphone using the website or the PWA application UDL Lite. It is also possible to send a download link via QR code using the UDL Helper extension.

mobile menu iconHow can I download an audio track (music) to MP3 "Уроки Python для начинающих | #6 - Циклы For, While, а также операторы"?mobile menu icon

  • The most convenient way is to use the UDL Client program, which supports converting video to MP3 format. In some cases, MP3 can also be downloaded through the UDL Helper extension.

mobile menu iconHow can I save a frame from a video "Уроки Python для начинающих | #6 - Циклы For, While, а также операторы"?mobile menu icon

  • This feature is available in the UDL Helper extension. Make sure that "Show the video snapshot button" is checked in the settings. A camera icon should appear in the lower right corner of the player to the left of the "Settings" icon. When you click on it, the current frame from the video will be saved to your computer in JPEG format.

mobile menu iconWhat's the price of all this stuff?mobile menu icon

  • It costs nothing. Our services are absolutely free for all users. There are no PRO subscriptions, no restrictions on the number or maximum length of downloaded videos.