Python Exercise #03: Create a Python program to calculate the area of a circle with radius r
Jul 1, 2025
Using the flowchart, create a Python program to calculate the area of a circle with radius r.
Python Exercise #03: Create a Python program to calculate the area of a circle with radius r
📘 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
📸 Instagram: https://www.instagram.com/pybeginners/
📢 Threads: https://www.threads.net/@pybeginners
🔗 LinkedIn: https://www.linkedin.com/in/joao-futi-muanda-16b980175/
Show More Show Less View Video Transcript
0:00
hello guys welcome back to the channel
0:02
John here so today let's try to solve
0:04
some Python exercise for the beginners
0:07
and we have the following question okay
0:09
using the flow shot create a Python
0:10
program to calculate the area of a
0:12
circle with radius R okay so this is the
0:16
our next challenge to create a Python
0:18
program so that can help us to create
0:20
the area of a circle with the radius R
0:22
okay so
0:25
uh this flowchart this program by just
0:28
looking okay i can see it's kind of a
0:30
very easy program okay and uh for the
0:33
tips I think I'm not there is some kind
0:35
of the formula of area as we can see
0:37
area is equal pi into r into r by 2 okay
0:44
constant p so we have the value of the
0:46
constant pi and boom boom so we have
0:49
kind of tips okay so now since I read
0:51
okay I have my question I have my
0:53
flowchart and let me jump into VS code
0:55
and let's start solving this program
0:57
itself okay so let me go and see
1:02
if you are someone who start learning
1:03
Python and want to practice Python code
1:05
this ebook that I create okay will help
1:07
you to practice Python with a visual
1:10
flowcharts so I create this book so that
1:12
you can create Python you can practice
1:13
Python okay so there are a lot of topics
1:15
that this ebook cover okay but this is
1:18
more recommended for beginners beginners
1:20
in Python or for those who starting
1:22
learning Python itself so there are a
1:24
lot of exercise that you can uh solve
1:27
you can go through this okay the most of
1:29
exercise they it has some of flow chart
1:31
so that will help you to understand the
1:33
program and to build your logical
1:35
thinking so apart of that this same
1:38
ebook okay there are kind of tips that
1:39
will help you okay to remember about
1:41
some Python topics that you can use
1:44
while solving this same problem uh the
1:46
same exercise so there are a lot of
1:48
exercise okay more than 30 exercise as
1:50
you can see most of them it has kind of
1:53
different problem different of challenge
1:55
okay so you can solve you can practice
1:58
Python by solving this same exercise so
2:01
I'll keep the link of this ebook okay in
2:04
the description in the description of
2:05
this video so that you can go grab it
2:08
and enjoy solving problems there okay
2:12
perfect so this is our thing that we
2:14
need to calculate we need to solve okay
2:16
a program that can help us calculate
2:18
this thing so this is the program from
2:20
the previous exercise okay just let me
2:22
create a new one i'm going to come here
2:25
as always let me say exercise
2:28
okay exercise_03
2:33
okay dotp
2:37
and then let me hide this and uh come
2:41
down and let's start solving the things
2:43
here okay close these guys close this
2:44
guy i don't need them i only need this
2:47
one okay let me close this a little bit
2:50
and boom so that I can have this and I
2:53
can see also the formula okay because I
2:54
need to know the value of the pi so this
2:57
is the value of the pi this is the
2:59
formula of area ah we already have it
3:02
and uh let me see okay so exercise first
3:05
I need first thing that I need to do as
3:07
always solve the simplest way possible
3:10
okay then after you solve in the
3:11
simplest way then you can try to change
3:13
the program to make it better okay so
3:15
let me comment first okay program or I
3:18
can just use okay Python program
3:21
to calculate the area of this guy boom
3:24
come here boom solve and they come here
3:27
little space come here boom a little
3:29
space
3:34
okay perfect so then after this so the
3:35
next thing that we need to do will be
3:37
something like this okay uh let's first
3:40
read the program okay get the flow shot
3:42
so that we can understand what we are
3:43
going to do he said read the radius
3:45
error so first we need to get the uh the
3:48
radius so that we can then go to
3:50
calculate the area so in order to get
3:52
the radius let me create a variable
3:53
called radius okay radius so we'll be
3:56
equal uh let's first let's give a let's
4:00
assume one now okay let's say five then
4:02
we need to get the area okay area will
4:06
be equal pi okay let me say pi into
4:12
r into r okay so it can be something
4:16
like this or here we have some the
4:19
formula of area okay r is equal p
4:21
into r boom boom boom okay something
4:23
like this so in Python in order to do
4:27
this okay we can do stuff like okay if I
4:32
yeah we can do something like this okay
4:35
by two so that mean this this means are
4:39
okay in power two perfect so then we
4:44
need the message so the message I'm
4:45
going to do print open and close so here
4:47
inside I'm going to say okay what I'm
4:49
going to print I'm going to print the
4:50
area as they say show area so that's why
4:53
I'm say print area perfect now save so
4:58
the next step now let me give the values
5:00
okay so here I put R but it's not R here
5:04
I use it radius okay so I'm going to
5:05
copy this guy come here and boom save
5:09
change okay radius radius so now for the
5:11
pi I don't have this variable so let me
5:13
create the pi so pi will be equal uh
5:17
what's the value of the pi 3.2
5:19
3.14
5:23
okay uh just let let's keep only one for
5:25
is enough and know that it's long it
5:27
keep just going on going on keep like
5:28
this perfect save
5:31
so now we have all the values so now let
5:33
me try to execute this and to see what's
5:36
going to happen save and if I run this
5:39
come a little up what say he gave us
5:41
78.5
5:43
wow what a fun is this okay
5:47
yeah okay uh this is correct okay let me
5:50
try radius radius so instead of a radius
5:53
I'm just going to give a big R itself so
5:56
that will be like a radius this also be
5:59
like big R radius perfect save
6:06
then if uh let me close this let me run
6:09
again
6:10
78 okay okay and if the radius of this
6:16
is like 100 safe and if I run again
6:24
and tree blah blah blah blah blah blah
6:26
okay perfect I see I don't understand
6:28
anything about geometry okay so I don't
6:31
know if there is correct or not but I
6:34
don't understand anything about geometry
6:36
but I think okay it's correct but okay
6:38
this r is not make is making me kind of
6:41
confused let me put R okay into oh
6:46
R into R something like this okay
6:51
save and if I run this ah perfect okay
6:55
okay the same thing perfect so now let's
6:57
try to change the program okay because
6:59
we don't need like to give a fixed
7:01
number okay as always so let's use input
7:03
so instead of 100 uh since this is a
7:05
radius so it's better if this value h
7:08
will be converted into float so let me
7:10
say float open and Close uh input
7:15
input open and close and let me do
7:18
something okay boom enter the
7:23
radius enter the radius okay of the
7:28
circle i think it's circle if I'm not
7:29
wrong yeah it's circle itself enter the
7:32
value of the circle give a little space
7:34
come boom then pi we didn't we don't
7:37
need to give like enter the value of the
7:39
pi no is the constant so then you do the
7:41
calculation then here let's print the
7:44
value okay I'm going to use f string as
7:45
always then I'm going to say okay the
7:49
radius
7:51
of the circle
7:54
is is what uh open and close i'm going
7:59
to use what area not the radius the area
8:03
of the circle the area okay the area of
8:07
the circle is blah blah blah like this
8:10
i'm going to give the area okay then I'm
8:13
going to save so if I run this again
8:16
and come a little up and I will enter
8:19
the radius of circle F if I give 10 boom
8:23
what going to give so the area of the
8:26
circle is 314
8:29
okay 0 so this is how you can solve okay
8:33
one of the way not this is how you can
8:35
solve but this is one of the way that
8:37
you can solve okay as I always say okay
8:39
there is a lot of way that you can solve
8:41
this same problem okay so this is one of
8:42
the way that I found but for sure you
8:45
will find a different way which is also
8:47
a better way okay so you can change you
8:49
can modify this same program okay you
8:51
can make it look good okay so this is
8:56
how I got okay the solution okay by
8:58
thinking so for sure you'll think in
9:00
different way and you can also correct
9:02
this mistake for for sure I did a lot of
9:04
mistakes here okay so you can correct
9:06
these mistakes in in the comment section
9:08
okay so we'll stay here and see you in
9:10
the next video and bye-bye
#Science
#Scripting Languages

