0:00
Hey everyone, welcome back to our Python
0:03
beginner series. Well, this Raju Lakmi
0:05
Singham and today's exercise looks very
0:08
simple, but it's one of the most
0:10
important building blocks in
0:11
programming. So, we are going to find
0:13
the largest number between two numbers.
0:16
And don't worry if you're new, I'll
0:18
explain this slowly, step by step, and
0:20
we'll even look at a flowchart first so
0:23
you can see the logic before we write
0:25
any code. Let's go. So here the user
0:29
will enter two numbers and our program
0:32
will check which one is bigger and then
0:34
it will display the largest number.
0:39
Simple, right? So you see enter first
0:41
number, enter second number and the
0:43
largest number is 8.0.
0:46
But how do we actually tell the computer
0:48
to do this? That is where logic comes
0:51
in. So whenever you are starting out,
0:54
flowcharts are your best friend. They
0:57
help you think like a programmer.
1:00
So here is the flow. At first it begins
1:03
the program begins and then it will take
1:05
the input of users which is a and b and
1:09
if a greater than b then you will show a
1:13
and if a is less than b that means if a
1:16
greater than b is false then you will
1:18
show b and then you will end the
1:23
Now let's turn this beautiful flowchart
1:26
into a Python code. Watch closely. So
1:49
Enter the first number
2:02
enter the second number.
2:11
And now you will check
2:30
then you will just print.
3:16
And yeah, that's it. So if you observe
3:18
the input, I didn't change it to any
3:21
data type. I didn't use any integer or
3:27
but if you observe if you check my
3:30
previous tutorials every time we take
3:32
input I told you that the input is by
3:36
default string right so we have to
3:39
convert it to either integer or either
3:41
float so when you're dealing with
3:43
mathematical operations always use float
3:46
so I'm using float here just to convert
3:49
the input from string to float
4:00
So this takes input from the user and
4:03
converts it to a number including
4:06
decimals. And then we store the first
4:09
number a and the second number b. And if
4:13
a is greater than b, it's
4:15
straightforward, right? You will just
4:17
print a. Else you will just print b. And
4:21
that's it. The computer follows the
4:22
exact same logic as our flowchart. And
4:26
if I run this program
4:33
and type 8 and five, see the largest
4:40
Exactly. That's what we expected. And
4:44
that's how you find the largest number
4:46
between two numbers using Python. See,
4:49
programming is not about memorizing
4:51
syntax. It's about learning how to think
4:54
step by step. That's why I showed you
4:57
the flowchart first. And also always
5:00
remember logic first, code second. If
5:04
you can explain it on paper, you can
5:06
write it in Python or in any programming
5:09
language. That is why I'm always you
5:12
know if you observe my tutorial you see
5:14
lot of exercises and most of them are
5:16
repeating according to the concept we
5:19
are including the new things in the same
5:21
program if you observe the flow of the
5:23
entire course. My main goal is to make
5:26
you feel as comfortable as possible in
5:29
dealing with logic and writing programs.
5:32
If you still have any doubts, if you
5:34
still feel anything not right, if you
5:37
still need more explanation, just let me
5:39
know. I'm going to make one more video.
5:41
If this video helped you understand even
5:43
a tiny bit better, do me a favor. Tap
5:46
that subscribe button and hit the like
5:48
button if you enjoyed the explanation
5:51
because here on this channel, we are
5:52
building your coding confidence one
5:55
exercise at a time. All right, friends,
5:58
keep practicing, stay curious, and I'll
6:00
see you in the next exercise.