Premium Only Content

Conditionals |Section 3|Celestial Warrior
1
00:00:00,620 --> 00:00:05,720
Hey, hello again. In this lecture you're going to learn
about conditionals. What is a conditional?
3
00:00:07,980 --> 00:00:14,190
Well a conditional is a block of code which
performs different actions depending on
5
00:00:14,190 --> 00:00:19,980
whether a given conditional evaluates to
true or false so let's go ahead and
7
00:00:19,980 --> 00:00:29,340
create a conditional in Python. I'll create the
file conditionals dot py and let me
9
00:00:29,340 --> 00:00:35,280
create a conditional block, and first of
all let me create a variable. Let's say a
11
00:00:35,280 --> 00:00:40,920
equals five and here I'll create a
conditional block. This block, what this
13
00:00:40,920 --> 00:00:48,780
will do is it will perform an action if
a is less than five and another action
15
00:00:48,780 --> 00:00:54,930
if a is equal or greater than five
so let me create that. If this, our
17
00:00:54,930 --> 00:01:04,049
conditional starts if a and let's say
less than five print, let's say less than 5.
19
00:01:04,049 --> 00:01:15,030
Press ENTER and if you want to perform
more actions with this conditional, with
21
00:01:15,030 --> 00:01:19,979
this condition so when this condition is
true this will be executed but if you
23
00:01:19,979 --> 00:01:25,049
want to perform more actions you can add
one there, if not then you can go to the
25
00:01:25,049 --> 00:01:32,159
next check.
So that would be else, so you have a
27
00:01:32,159 --> 00:01:45,060
column here, a column there, so else print
equal or greater than 5. Now let me
29
00:01:45,060 --> 00:01:53,520
execute it. And we get equal or greater
than 5. So why did you get that? Well
31
00:01:53,520 --> 00:01:59,729
because you know if a is less than 5
which is not, so this evaluates to false,
33
00:01:59,729 --> 00:02:05,340
that means with this this will not be
executed so Python will skip this line
35
00:02:05,340 --> 00:02:12,870
and it will go to the next one. This next
line says else, so else means if this
37
00:02:12,870 --> 00:02:18,450
is not true,
this will be executed, so equal or
39
00:02:18,450 --> 00:02:25,769
greater than five, so in this case if a
is not less than five then there's no
41
00:02:25,769 --> 00:02:32,549
other option but a is either equal or
greater than five, so that's an if and else
43
00:02:32,549 --> 00:02:36,959
conditional block. However if you want to
add more conditions there
45
00:02:36,959 --> 00:02:45,569
you want to use elif, so let's do that
the first two lines stay the same. If a
47
00:02:45,569 --> 00:02:57,840
is less than five print less than five
elif a is equal to five print equal to
49
00:02:57,840 --> 00:03:19,019
five else print greater than five. Save
and execute and you get equal to five.
51
00:03:19,019 --> 00:03:21,769
If a was six,
you'd get greater than five and if a was
53
00:03:25,500 --> 00:03:34,500
three you'd get less than five.
That's a conditional block in Python and
55
00:03:34,500 --> 00:03:39,480
yeah, try to get familiar with the syntax
and in the next lecture I'm going to
57
00:03:39,480 --> 00:03:47,569
incorporate a conditional with this
block of code, so see you there.
-
LIVE
Side Scrollers Podcast
2 hours agoThe BIGGEST FLOP of 2025 | Side Scrollers Live
306 watching -
LIVE
LFA TV
18 hours agoFORCE PEACE IN THE MIDDLE EAST! | LIVE FROM AMERICA 6.13.25 11AM
1,841 watching -
LIVE
The Big Mig™
1 hour agoGlobal Finance Forum From Bullion To Borders We Cover It All
63 watching -
LIVE
Rebel News
48 minutes agoIsrael strikes nuclear sites and Iran retaliates, Rebel News fights for G7 access | Rebel Roundup
483 watching -
1:30:03
Steven Crowder
3 hours agoIsrael Strikes Iran: Does this Really Mean War for America & How Does Trump Respond
178K178 -
LIVE
Viss
2 hours ago🔴LIVE - The PUBG Tactics You Need To Win Battle Royales Consistently!
123 watching -
1:05:28
The Rubin Report
2 hours agoBREAKING: Trump Issues Chilling Reaction to Iran After Israel Attacks
26.4K88 -
LIVE
GloryJean
3 hours agoMnK #1 Aggressive POV 🖱️ 6.7 K/D
39 watching -
LIVE
Film Threat
15 hours agoHOW TO TRAIN YOUR DRAGON + TONS OF REVIEWS | Film Threat Livecast
126 watching -
LIVE
Flyover Conservatives
13 hours agoWarning & Wisdom: Prophetic Word about Israel and Iran—and 6 Steps to Build Your Business Now with Clay Clark | FOC Show
365 watching