Premium Only Content
![Loops |Section 4|Celestial Warrior](https://1a-1791.com/video/s8/1/4/S/0/k/4S0kk.qR4e-small-Loops-Section-4Celestial-Wa.jpg)
Loops |Section 4|Celestial Warrior
1
00:00:00,050 --> 00:00:06,420
Hey, in this lecture you'll learn about loops
and loops are very important.
3
00:00:06,420 --> 00:00:10,590
They are one of the fundamental building
blocks of the Python programming language
5
00:00:10,590 --> 00:00:15,809
and of every other programming language
as well because loops are crucial.
7
00:00:15,809 --> 00:00:21,630
So what are loops? Well loops are basically
the way that allows you to execute the
9
00:00:21,630 --> 00:00:26,789
statement multiple times, so what does
that mean? Let's say you have a bunch of
11
00:00:26,789 --> 00:00:32,040
files, text files and you want to insert
a certain string inside each of these
13
00:00:32,040 --> 00:00:37,140
text files, so you'd have to open those
text files in Python by writing the
15
00:00:37,140 --> 00:00:42,090
Python code that corresponds to opening
a file and then you insert that string
17
00:00:42,090 --> 00:00:46,649
inside the file and close the file and
save it, so there is some code that does
19
00:00:46,649 --> 00:00:52,199
this opening and inserting the text and
closing the file and if you had 100
21
00:00:52,199 --> 00:00:57,570
files you'd have to execute that code
100 times so you'd come up with let's
23
00:00:57,570 --> 00:01:03,480
say 100 lines of code but that doesn't
sound very efficient so that's what loops
25
00:01:03,480 --> 00:01:08,970
are for. So a productive way to solve the
problem that I just mentioned would be
27
00:01:08,970 --> 00:01:13,530
to create a list of these files so
Python lists all of the file names and
29
00:01:13,530 --> 00:01:20,310
then you would use a loop to iterate
through this list of file names and a loop
31
00:01:20,310 --> 00:01:25,439
would do all that in just a few lines of
code and there are two kinds of loops in
33
00:01:25,439 --> 00:01:30,240
Python, there is a for loop and a problem
for example that I just mentioned would
35
00:01:30,240 --> 00:01:36,600
be solved using a for loop and we also
have the while loop. A while loop does
37
00:01:36,600 --> 00:01:41,700
also repeatedly execute a statement
that you give, that you write and it
39
00:01:41,700 --> 00:01:47,280
executes it as long as the given conditional
true, so let's say you have a user that
41
00:01:47,280 --> 00:01:52,770
is trying to login in your web app and
while he keeps entering their own
43
00:01:52,770 --> 00:01:59,130
password, you'd continue executing a
statement that would reject his login to
45
00:01:59,130 --> 00:02:04,049
your system, so while the password is
wrong reject the user, something like that.
47
00:02:04,049 --> 00:02:09,149
So that's about the definition of
the for loop and the while loop. In our
49
00:02:09,149 --> 00:02:14,370
next lecture I'll show you the syntax of
the for loop and by also looking at an example,
51
00:02:14,370 --> 00:02:18,329
so see you in the next lecture.
-
LIVE
The Officer Tatum
1 hour agoLIVE: Delta Airlines CRASH BLAMED On Trump, Ashley St. Claire Had Elon's BABY? + More | Ep 63
965 watching -
1:38:08
vivafrei
3 hours agoAOC goes Full Criminal Lover? Mehdi Hasan Goes Full Terrorist? Another Plane Crash & MORE! Viva Frei
38.5K10 -
1:52:19
Russell Brand
3 hours agoLIVE FROM MAR A LAGO: US, Russia & China to Negotiate While UK Ramps Up in Ukraine – SF539
101K34 -
1:59:46
The Charlie Kirk Show
2 hours agoThe Biggest Fraud in History? + Russian Peace Talks + Unhappy Boomers? | Gingrich, Rasmussen | 2.18
61.5K24 -
58:11
The Dan Bongino Show
5 hours agoThis Is What Winning In Politics Looks Like (Ep. 2425) - 02/18/2025
668K1.03K -
2:16:49
Steven Crowder
5 hours ago🔴 WINNING: Why Trump Has John Oliver & All of Europe Freaking Out
436K265 -
1:04:20
Timcast
4 hours agoDemocrats Plan COUP In NYC After Mayor Defends Trump, Lets ICE Deport Criminals | Timcast LIVE
88.1K46 -
55:23
TheAlecLaceShow
2 hours agoGuest: Victor Avila | Left Blames Trump For Canada Plane Crash | Tom Hanks TDS | The Alec Lace Show
16.5K1 -
23:23
marcushouse
13 hours ago $0.32 earnedSpaceX Just Smashed Multiple Records! Wow!
12.9K4 -
2:03:03
LFA TV
18 hours agoTRILLIONS IN FRAUD & WASTE FOUND! | LIVE FROM AMERICA 2.18.25 11AM
68.9K18