Python Exercise #02: Create a Python program to calculate interest on a bank deposit
Jun 26, 2025
With the help of flowchart, create a Python program to calculate interest on a bank deposit Python Exercise #02: Create a Python program to calculate interest on a bank deposit š Python Exercises for Beginners ā Practice and improve your skills! š Access here: https://buymeacoffee.com/usandopython/e/396802 ā”ļø Connect with me on: š Website: https://www.pybeginners.com/en/ šø Instagram: https://www.instagram.com/pybeginners/ š¦ Twitter: https://x.com/joaofuti_ š¢ Threads: https://www.threads.net/@pybeginners š LinkedIn: https://www.linkedin.com/in/joao-futi-muanda-16b980175/
View Video Transcript
0:01
hello guys welcome back to the channel
0:03
sean here so today let's try to solve
0:05
our second exercise for this Python
0:08
exercise for beginners okay so as always
0:10
we have our question let's see with the
0:12
help of flowshot create a Python program
0:14
to calculate interest on a bank deposit
0:17
so we have here our flow short
0:21
this flowshot will help us to understand
0:23
how we can build this uh program okay so
0:26
he said first we need to read the value
0:27
years and rate okay then we need to
0:29
calculate the interest amount years rate
0:32
by interest okay then we show the we
0:34
need to show the interest so we have
0:36
some tips here that we can use to help
0:38
us solving this same problem okay so
0:41
let's try to solve this uh let's jump
0:44
into our VS code and start immediately
0:46
solving the same problem
0:50
see if you're someone who start learning
0:52
Python and want to practice Python code
0:54
this ebook that I create okay will help
0:56
you to practice Python with a visual
0:59
flowcharts so I create this book so that
1:01
you can create Python you can practice
1:02
Python okay so there are a lot of topics
1:04
that this ebook cover okay but this is
1:07
more recommended for beginners in Python
1:09
or for those who starting learning
1:11
Python itself so there are a lot of
1:13
exercise that you can uh solve you can
1:16
go through this okay the most of
1:18
exercise it has some of flowchart so
1:21
that will help you to understand the
1:22
program and to build your logical
1:24
thinking so apart of that this sembook
1:27
okay there are kind of tips that will
1:29
help you okay to remember about some
1:30
Python topics that you can use while
1:33
solving this same problem uh the same
1:36
exercise so there are a lot of exercise
1:38
okay more than 30 exercise as you can
1:40
see most of them it has kind of
1:42
different problem different of challenge
1:44
okay so you can solve you can practice
1:47
Python by solving this same exercise so
1:50
I'll keep the link of this ebook okay in
1:53
the description in the description of
1:54
this video so that you can go grab it
1:57
and enjoy solving problems so perfect we
2:01
have the question and we have the
2:02
exercise the flowshot that can help us
2:04
and we have also some tips Okay so tips
2:07
we have some kind of the formula of the
2:09
interest uh calculation okay so there is
2:12
a lot of way that we can calculate the
2:14
interest okay uh depend because see as I
2:17
said I I do understand very well ma
2:19
mathematics but this is one of the
2:22
formula that I found okay so if you
2:24
found another formula you can also use
2:26
that form to try to to solve this same
2:29
problem so let's try to solve this by
2:32
following this flowchart so uh the first
2:35
thing that we need to do is I need to
2:36
create a new script okay this is from
2:38
the past exercise one so this is second
2:40
exercise let me create a new script i'm
2:42
going to come here okay I'm going to
2:43
create a kind of an exercise
2:46
exercise zero
2:50
two okay do
2:53
I'm going to do this and then let me
2:56
hide this one and this is where I'm
2:58
going to write the program okay close
2:59
this guy and let me see how the flow
3:03
goes okay uh if I come here so first as
3:06
I said as I used to say okay first try
3:08
to solve it in the simplest way possible
3:10
okay so the simplest way possible will
3:12
be something like this okay let me
3:13
comment first okay uh program
3:17
to to what what is the program uh
3:21
program to calculate interest and loan
3:23
okay let me just copy this
3:26
okay
3:27
so that I can remember you go go and
3:30
boom past here don't need to worry you
3:32
just come up boom program to calculate
3:35
in the rest of the posit perfect then I
3:38
come here and go down
3:41
and Ctrl Z boom
3:44
okay there first we need to read the
3:46
value okay so I'm going to create a
3:47
variable called value so this value will
3:50
be equal uh okay first let's assume that
3:55
uh will be 500 okay 500 USD can be also
3:58
then after that I'm going to I need to
4:00
get the years okay of the loan so years
4:04
let me say for two years okay perfect
4:07
and after this we need the rate okay so
4:10
the rate so this rate let's say on
4:13
interest of at least like 5% okay it
4:17
will be percent
4:19
uh cut down So then we need to calculate
4:23
the interest so I'm going to say
4:25
interest
4:27
oh mistake interest will be equal equal
4:31
what amount of amount years and rate
4:34
okay so the amount is practically the
4:36
value okay uh into
4:40
into what into rate
4:44
into into
4:46
uh amount oh I forgot years into years
4:52
okay into
4:54
rate
4:56
by 100 rate by 100 okay
5:01
into rate by 100 oh now I'm kind of a
5:05
little confused is this everything by
5:08
100 or only rate by 100 now I'm I'm
5:12
confused okay because as I say I'm not
5:15
good with math so now I don't know the
5:17
formula properly so uh let me say but
5:20
here the it has like a principle into
5:23
interest rate into time okay so the time
5:27
time is here practically is the years
5:29
itself perfect interest rate interest
5:32
rate is this guy and this is the
5:34
principal principal is kind of the value
5:36
is the amount so I think rate will be by
5:39
100 itself only rate so then I can do
5:41
like this and boom so rate is the only
5:44
one will be by 100 if I'm not wrong okay
5:47
because or else they could have put all
5:50
this stuff inside of arenas but let's
5:53
keep like this so then after that let's
5:55
show the interest okay let's say print
5:58
that I'm going to print I'm going to
5:59
print interest okay interest perfect
6:02
save
6:06
so now let me try to run this to see how
6:09
what is the output
6:14
uh what it give us it give us 50 okay so
6:19
the interest rate will be like 50 okay
6:21
the amount for for two years and on rate
6:24
of 5% of five itself okay will be like
6:29
50 50 will be the interest okay that the
6:33
person will pay extra but uh okay for if
6:37
interest is 15 save and if I run this
6:41
will be on 150 uh exactly perfect I
6:45
think it's working now so now as you
6:47
said okay we just wrote the program now
6:48
let's try to organize this program
6:50
properly because this doesn't make sense
6:52
and we cannot have like fixed number
6:54
okay the numbers must be the value must
6:56
be entered by user so here okay first
7:00
let's try to change the things okay so
7:01
this variable first first of all I
7:04
didn't like it so it's better if we call
7:06
it amount than value okay so
7:09
now just let's change this okay let me
7:11
say let's call it amounts okay uh
7:15
instead of value by let's call it amount
7:18
okay as I like to say okay first solve
7:20
in the first simplest way possible okay
7:22
then after that start making some change
7:23
so that the program can look better okay
7:26
so now let's say something like okay
7:27
let's use input input open and close and
7:31
let's tell them okay but see since this
7:33
is a value is better if we convert this
7:35
into float values okay so let's say
7:38
float open and come here and close now
7:42
here inside let's say okay and enter
7:46
enter the amount enter the amount okay
7:51
enter the loan amount enter the loan
7:54
amount enter the loan amount okay let's
7:57
put here dot and give a little space
8:00
perfect okay so after loan amount what
8:03
we need uh we need also this years okay
8:06
so years let's say okay uh layer must be
8:10
int okay must be integer because there
8:12
is no dot to years something like not
8:14
only integer but int int what int input
8:18
open and close close again and this two
8:21
by and what we need to say okay and
8:24
let's say okay enter
8:27
the time
8:29
in years enter the time in years for the
8:35
loan for alone okay dot give a little
8:38
space boom i think this message is
8:40
better okay so you can create a better
8:42
main one me this is the only one that
8:43
came on my head right now perfect then
8:46
for the rate okay uh rate is we can use
8:50
float no problem okay because it's just
8:52
a rate because it can be a a decimal
8:54
number float number so that's why let's
8:57
use float okay open and close here
9:00
that's the input okay open and close
9:03
again let me delete this guy bye-bye and
9:06
here inside let's say something like uh
9:08
okay enter
9:11
enter the interest
9:16
rate enter interest rate boom boom save
9:20
okay now we have a good message so for
9:24
interest blah blah blah is going to
9:26
calculate out of this thing perfect now
9:28
for the message okay for the results for
9:31
the output so for the output let's say
9:33
something like this okay i'm going to
9:34
use F string okay uh F string okay then
9:38
I'm going to do this so after this what
9:41
I'm going to do and I need to format a
9:44
good for a good message okay let me see
9:45
okay and the what is the name of the
9:49
program python program to calculate
9:50
interest on a bank depos okay so the
9:56
bank deposit the interest on the bank so
9:58
the the interest Okay the inest
10:04
interest
10:05
amount
10:08
for your loan
10:12
will be okay yeah will be since it's a
10:14
calculator it's better will be okay will
10:17
be give a little space then uh let's
10:20
give the interest itself okay in
10:26
interest okay this way then
10:30
okay then let's put here for examp if it
10:34
is USD let's put just boom USD something
10:36
like this okay and save so now let's run
10:40
this guy to see what we got if you got
10:42
some errors or if everything is correct
10:44
boom he said enter the loan amount the
10:46
loan amount so I want like 5 $150 okay
10:50
boom enter the time year so the time I
10:52
need I want to pay it in two years then
10:55
he say enter the interest rate for the
10:56
interest rate will be like agreement
10:59
will be like for 5% no 9 8% itself only
11:03
then boom what say the interest amount
11:05
for your loan will be $240.0
11:08
0 okay so this way I just solve the our
11:11
second exercise okay as I said okay
11:13
there is a lot of way that you can solve
11:14
this exercise okay even you can make
11:16
this program better so this is the way
11:18
that I found okay but you you can find
11:20
another way okay so as I said okay you
11:22
can get this same ebook that I'm using
11:24
to practice this exercise okay the link
11:26
will be in the description of the video
11:28
you can go there and get this same ebook
11:29
okay so we'll save from here okay then
11:32
I'll see you guys in the next exercise
11:35
okay bye
#Banking
#Programming