Python Exercise #02: Create a Python program to calculate interest on a bank deposit
Apr 24, 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
Support The Channel š
š You can support me directly with a donation on Buy Me a Coffee.
https://buymeacoffee.com/pybeginners
Every contribution, no matter how small, makes a difference! š
ā”ļø Connect with me on:
š Website: https://www.usandopy.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/
Show More Show Less 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
0:20
short This flowshot will help us to
0:22
understand how we can build this uh
0:25
program Okay So he said first we need to
0:27
read the value years and rate Okay Then
0:29
we need to calculate the interest amount
0:30
years rate by interest Okay then we show
0:33
the we need to show the interest So we
0:36
have some tips here that we can use to
0:38
help us solving this same problem Okay
0:41
so 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 calculation Okay So there is a
2:12
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
2:45
exercise exercise
2:49
zero two Okay
2:52
do 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
3:16
program to to what is the program uh
3:21
program to calculate interest and loan
3:23
Okay let me just copy this
3:26
Okay So that I can remember you go go
3:30
and boom past here Don't need to worry
3:32
You just come up Boom Program to
3:35
calculate in the rest of the posit
3:37
Perfect Then I come here and go
3:40
down and Ctrl Z
3:43
Boom Okay There first we need to read
3:46
the 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
4:18
percent uh cut down So then we need to
4:23
calculate the interest So I'm going to
4:25
say
4:26
interest oh mistake interest will be
4:30
equal equal what amount of amount years
4:34
and rate okay so the amount is
4:36
practically the value okay uh
4:39
into into what into
4:43
rate into into
4:46
uh amount oh I forgot years into
4:51
years okay
4:53
into
4:55
rate by 100 Rate by 100
5:00
Okay Into rate by 100 Oh now I'm kind of
5:05
a 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
5:57
print that I'm going to print I'm going
5:59
to print interest okay interest perfect
6:05
save so now let me try to run this to
6:09
see how 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:30
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
7:08
So now just let's change this Okay Let
7:11
me 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
7:45
enter enter the amount Enter the amount
7:50
Okay Enter the loan amount Enter the
7:54
loan amount Enter the loan amount Okay
7:57
Let's put here dot and give a little
7:59
space Perfect Okay So after loan amount
8:02
what we need uh we need also this years
8:06
Okay So years let's say okay uh layer
8:09
must be int okay must be integer because
8:11
there is no dot to years something like
8:14
not only integer but int int what int
8:17
input open and close close again and
8:20
this two bye-bye and what we need to say
8:23
okay and let's say okay
8:26
enter the
8:28
time in years enter the time in years
8:32
for
8:34
the loan for alone Okay Dot Give a
8:37
little space Boom I think this message
8:40
is better Okay So you can create a
8:41
better main one Me this is the only one
8:43
that came on my head right now Perfect
8:46
Then for the rate Okay Uh rate is we can
8:49
use float No problem Okay Because it's
8:52
just a rate because it can be a a
8:54
decimal number float number So that's
8:57
why let's use float Okay Open and close
8:59
here That's the input Okay Open and
9:03
close again Let me delete this guy
9:05
Bye-bye And here inside let's say
9:07
something like uh okay
9:10
enter enter the
9:15
interest rate Enter interest rate Boom
9:19
Boom Save Okay Now we have a good
9:22
message So for interest blah blah blah
9:25
is going to calculate out of this thing
9:27
Perfect Now for the message Okay For the
9:30
results for the output So for the output
9:33
let's say something like this Okay I'm
9:34
going to use F string Okay Uh F string
9:37
Okay Then I'm going to do this So after
9:40
this what I'm going to do and I need to
9:43
format a good for a good message Okay
9:45
Let me see Okay And the what is the name
9:48
of the program python program to
9:50
calculate interest on a bank depos Okay
9:54
So the bank deposit the interest on the
9:58
bank So the the interest Okay The
10:03
inest
10:04
interest
10:07
amount for your
10:11
loan will be okay Yeah Will be since
10:14
it's a calculator is better will be Okay
10:16
Will be give a little space Then uh
10:19
let's give the interest itself Okay
10:25
In interest Okay This way
10:29
then Okay Then let's put here for examp
10:33
if it is USD Let's put just boom USD
10:36
Something like this Okay And save So now
10:39
let's run this guy to see what we got If
10:41
you got some errors or if everything is
10:44
correct Boom He said enter the loan
10:46
amount The loan amount So I want like 5
10:48
$150 Okay Boom Enter the time year So
10:52
the time I need I want to pay it in two
10:54
years Then he say enter the interest
10:56
rate for the interest rate will be like
10:58
agreement will be like for 5% no 9 8%
11:02
itself only then boom what say the
11:04
interest amount for your loan will be
11:06
$240.0
11:08
$0 Okay so this way I just solved the
11:11
our 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
#Financial Planning & Management
#Scripting Languages

