0:00
Hey friends, welcome back to Simplified
0:03
by Singum. Welcome to our Python
0:05
beginner series. So in today's exercise,
0:08
it is super interesting because we are
0:09
going to write a Python program that
0:11
finds the largest value among the
0:13
numbers. And this is exercise six. And
0:16
trust me, by the end of this video, you
0:19
will not only know how to solve this
0:21
problem, but also understand the
0:23
stepbystep flowchart of how Python makes
0:30
So before we jump into code, let's look
0:32
at the flowchart because flowcharts help
0:35
us visualize the logic like a road map.
0:38
And here we start with taking three
0:42
inputs A, B and C. And first we compare
0:45
A with B. If A is greater than B, then
0:49
we check if A is greater than C.
0:53
If yes then we say that A is the largest
0:58
or else we say that the C is the largest
1:03
but if it's not A greater than B then we
1:06
compare B and C then if B greater than C
1:11
then we display B else we display C and
1:14
then we end the program. Simple right?
1:18
Step by step we eliminate until we find
1:23
Now let's write this in Python. Always
1:44
Enter the first number.
1:53
Enter the second number.
2:11
enter the third number.
2:19
Obviously here we are doing mathematical
2:22
calculations. So I will do it float. You
2:25
can give int. It's your choice but I'm
2:48
Now we check the conditions based on the
2:53
So if you observe the flowchart, if a is
2:55
greater than b, then you check if a is
2:58
greater than c. Right? Okay.
3:02
So if a is greater than b
3:09
if a is greater than c now you check
3:12
whether a is greater than c or not. If a
3:15
is greater than c then you will just
3:17
create a variable called largest and you
3:19
store a here. Else you store
3:33
If a is greater than b is false then you
3:36
will check b greater than c. So if b is
3:39
greater than c you display b else you
3:41
display c. So if b greater than c
4:07
and then you will just print the
4:10
largest number. So print
4:15
the largest number is
4:25
Okay. And now let's check by giving the
4:28
inputs. So maybe a value is 10 and b
4:37
is maybe 12. Okay. So now a value is 10,
4:42
b value is 7 and c value is 12. So is 10
4:46
greater than 7? Is 10 greater than 7?
4:51
True. And now it goes here. Is 10
4:55
greater than 12? Is 10 greater than 12?
4:59
No, this is false. Actually here it will
5:01
be C. That is why tracing is really
5:05
Now the computer goes to the else part
5:08
and obviously if A is greater than C is
5:10
false then the largest will be C. So
5:13
that is what we are printing here.
5:18
So the largest will be C. So this is how
5:20
you have to trace by giving the numbers
5:22
by giving some conditions. What if A is
5:24
greater than B? What if B is greater
5:27
than A and C and what if C is greater
5:29
than A and B. So if you give multiple
5:31
conditions and multiple cases then you
5:33
will understand the you know up to what
5:36
extent you have to solve a particular
5:38
problem or up to what extent you have to
5:40
write a code to solve that particular
5:43
problem once again. So let's break this
5:46
down briefly. So first we take three
5:49
inputs from the user and we are
5:50
converting them to floats. So we can
5:55
and then comes to the logic. If a is
5:57
greater than b then python checks if a
6:00
is greater than c. If yes then the
6:02
largest will be a else the c will be the
6:05
bigger. But what if a is not greater
6:08
than b. So now the computer goes to else
6:11
part and it will compare b with c. If B
6:14
is greater than C, then the largest will
6:16
be B. Otherwise, C will be the largest.
6:20
Finally, we printed the result. And
6:22
let's test it quickly.
6:30
What if the first number is 10 and the
6:32
second number is 25 and the third number
6:38
The largest is 25. Good job.
6:42
And also in order to handle the
6:50
the inside the brackets
7:03
So it is handling decimals perfectly. So
7:06
that's really an awesome job. And you
7:08
just learned how to compare three
7:09
numbers step by step in Python. Always
7:12
always try to visualize before coding.
7:15
And if you found this video helpful, do
7:17
me a small favor. Hit that like button,
7:19
share it with a friend who is learning
7:21
Python, and most importantly, subscribe
7:23
to this channel so you don't miss the
7:25
next exercise because trust me, every
7:28
video takes you one step closer to
7:31
becoming a confident Python programmer.
7:33
See you in the next one and until then,
7:35
keep coding and keep growing.