Welcome to PyBeginners β your go-to place to learn Python programming the easy way! π
Whether you're starting from scratch or revisiting the basics, this channel is built just for YOU. We break down Python concepts into bite-sized, beginner-friendly videos using real-life examples, everyday language, and fun visuals.
Think of PyBeginners as your coding buddy β here to help you:
β
Understand the why behind every concept
β
Build confidence, one small step at a time
β
Learn coding without feeling overwhelmed
π Check out more learning resources:
π Blogs: https://www.pybeginners.com/
πΌ LinkedIn: https://www.linkedin.com/newsletters/pybeginners-7267881715929415681/
π Free eBooks & PDFs: https://www.usandopy.com/livros/
π New videos every week β covering Python basics, hands-on exercises, projects, and career tips!
π Subscribe, join the PyBeginners family, and let's make Python simple together π»π¬
#LearnPython #PyBeginners #PythonForBeginners #PythonMadeEasy
Show More Show Less View Video Transcript
0:00
Hey guys, welcome back to Simplified by
0:02
Singam. Well, today we are going to
0:04
solve Python exercises. So, the concept
0:08
is pretty simple. So, we have actually
0:10
created these Python exercises so so
0:13
that each and every beginner out there
0:15
can These exercises can help them
0:17
somehow to implement the Python in the
0:20
real world. Like how can we use this
0:23
Python in the real world problems? Like
0:25
how can we write solve the problems in
0:28
the form of logic? So, that these
0:31
exercises can help each and every person
0:34
to understand the fundamentals and just
0:37
they can be pretty clear by solving the
0:38
real world problems. Like the concepts
0:41
are actually we have involved variables,
0:44
simple operations, and basic logic with
0:47
straightforward problems. These levels
0:49
are like I guess all of these problems
0:52
are really easy to understand and easy
0:54
to solve. And also, I will be here with
0:56
you solving and we will solve this
0:59
together for sure.
1:01
So, we have also involved some
1:04
I can say that science related problems
1:07
and also it's like maths and physics
1:08
related problems so that each and every
1:10
person can be involved in this.
1:13
So, today we are going to solve the
1:15
concept of compound interest. So, like
1:18
So, we have exercise and in that we'll
1:22
be having a concept along with the
1:24
formula so you don't have to worry about
1:26
that. So, we have actually showed you
1:29
like how the how to solve
1:32
by you know, giving you the hint already
1:34
and you can solve and you can see here
1:37
we have a problem along with expected
1:40
output. So, we have to solve the problem
1:43
according to that.
1:44
So, what we have to do is first we will
1:47
understand the concept of compound
1:49
interest and then we will see the
1:50
formula and then we have to read the
1:52
problem and then according to the
1:54
formula we have to solve the problem.
1:57
It's pretty simple. All we have to do is
1:59
we have to write the Python code to
2:01
solve a particular problem and the
2:02
concept is right there.
2:05
So first, let us understand what exactly
2:08
a compound interest is. So compound
2:10
interest is actually
2:12
the interest that we calculate according
2:15
to the initial value, the initial value
2:17
that we give. For example, I'm the
2:19
person I'm giving you the loan like for
2:22
about 100 100,000 dollars, okay?
2:25
So I have to calculate the compound
2:28
interest and I give you time for about 3
2:31
years and it's the rate of interest is
2:33
10%. So you have to pay me the 10% of
2:38
the amount of the actual amount, that
2:41
means 100,000 dollars.
2:43
Like whatever it could be for 3 years,
2:47
whatever will be the value, you have to
2:49
pay me. So which is nothing but the
2:51
compound interest. So first, this is
2:55
what compound interest is basically. So
2:57
it's the amount times the rate
3:01
times the time.
3:03
So which is the principal amount into
3:06
the rate that I'm giving it to you in
3:09
the time and whatever time it might take
3:12
for you to clear it.
3:14
So the formula is pretty simple. So the
3:16
actual amount will be
3:18
the principal amount into 1 plus R is
3:21
nothing but the rate of interest
3:24
and the time, power the time.
3:27
So this is how we will calculate the
3:28
compound interest and it's a basic
3:30
formula that every person will use in
3:33
the real time to solve to get the
3:34
compound interest. And how we can solve
3:36
this problem using Python? So that is
3:39
what we are going to do it today.
3:42
So as I said before,
3:44
here's a person who gave 100,000 dollars
3:47
at an annual interest rate is 10% for 3
3:50
years.
3:51
So we have to find the final value of
3:53
the investment and the final amount is
3:56
this one.
3:59
Okay, let's see. So, I have kept
4:01
everything here so you can see the
4:02
concept, the formula, and the problem.
4:05
So, as of now, we have already seen all
4:07
this. So, let's just copy the formula
4:10
and the amount.
4:12
So, now already the interpreter is
4:14
throwing errors on our face saying that
4:16
what is principal amount and what is the
4:18
rate of interest and what are all these
4:20
variables? It's like I'm confused. Don't
4:23
worry, let's work on it.
4:25
So, first, the principal amount is
4:27
100,000.
4:30
Okay.
4:32
And the annual rate is, which is nothing
4:34
but
4:36
R
4:37
according to the formula, is three Oh,
4:40
sorry, is 10%. That means 10 by 100,
4:45
which is nothing but 0.1. So, 0.1.
4:49
And the time is nothing but T according
4:51
to the formula and it's 3 years, right?
4:55
So, usually computer will not understand
4:58
this, especially our Python will not
5:00
have this.
5:01
So, obviously it will throw error. So,
5:03
instead, it uses power.
5:06
So, this thing.
5:07
And now,
5:10
we will just
5:12
print A.
5:14
Nothing fancy, just print A.
5:18
Okay.
5:21
And it will show you some weird value if
5:23
I'm not wrong.
5:25
Okay, it didn't understand. If you see,
5:27
int object is not callable.
5:30
Obviously, because here
5:34
it's thinking something else.
5:37
And now, let's see again.
5:42
So, it is giving us a weird value. The
5:44
output we need is this thing, but it is
5:46
actually giving us something else. In
5:49
order to make it up to two points,
5:52
all you have to do is just
5:57
point
6:02
And yeah.
6:04
And this here we are actually using F
6:07
strings.
6:08
So, the actual amount is
6:18
this much.
6:21
So, when you run it, you see the actual
6:24
amount is this thing.
6:26
Okay, sounds good. Yeah, that's it. So,
6:29
this is how we solve the real-world
6:31
problems. This is the first exercise
6:34
that we have actually worked on. So, we
6:36
know the concept of compound interest
6:38
and we have the formula already. This
6:40
cap is nothing but it's the power
6:42
square.
6:43
So, in our in our cases in programming
6:45
language, square is something like this.
6:47
It looks something like this. So,
6:49
there's a person who invested $100,000
6:52
at an annual interest rate for about 10%
6:55
for 3 years. So, the problem is that.
6:58
So, we need the actual amount.
7:00
So, we have already know the formula.
7:03
So, we can just give the amount and the
7:06
rate and three
7:09
and the formula you just have to, you
7:11
know, put everything together and to get
7:12
the output. And the interesting thing is
7:15
here we have actually used F strings.
7:17
So, F strings
7:19
F strings. So, we use that
7:23
to actually substitute the value inside
7:26
the brackets. And here we need it up to
7:29
two decimals, and that's the reason we
7:31
used this weird syntax to get the two
7:34
decimals.
7:36
You got me, right? So, this will be the
7:39
actual amount. And also, we can do
7:41
something like we can actually get the
7:44
input from the user. So instead of this
7:47
you can do something like int of input.
7:51
You can add something like enter the
7:53
principal amount.
8:04
Mhm, enter the principal amount and give
8:06
some space
8:08
and the rate of interest we need this in
8:10
float.
8:16
input
8:19
rate of interest
8:24
Okay and
8:27
time will be integer so
8:30
input
8:31
Sometimes it will be float as well like
8:33
3.5 months, sorry 3.5 years or 3.6
8:37
something.
8:38
Maybe it depends upon the situations in
8:40
the problem that we are looking at.
8:42
And enter the time so
8:55
And this will calculate it and it will
8:58
give us the output.
8:59
So the principal amount 100,000
9:03
and rate of interest 3.1
9:06
and enter the time three so
9:10
This is how we can give
9:11
you know input as well.
9:15
I hope you guys understand this. Every
9:17
day, remember every day at this time I
9:20
will be posting one exercise. You guys
9:23
can come here every day and let's see
9:26
what's going on here and we will solve
9:28
everything together. And I'll be there
9:31
and if you still have any doubts, I will
9:33
be there. Just comment down below and we
9:35
will solve and we will maybe I will talk
9:38
about the comments in the upcoming
9:40
episodes as well. See you in the next
9:43
one.
#Science

