Python Exercise #03: Create a Python program to calculate the area of a circle with radius r
Apr 24, 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
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: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:23
okay so uh this flowchart this program
0:28
by just looking okay i can see it's kind
0:30
of a very easy program okay and uh for
0:33
the tips I think I'm not there is some
0:35
kind of the formula of area as we can
0:37
see area is equal pi into r into r by 2
0:43
okay constant p so we have the value of
0:46
the 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
1:01
see if you are someone who start
1:03
learning Python and want to practice
1:05
Python code this ebook that I create
1:06
okay will help you to practice Python
1:09
with a visual flowcharts so I create
1:11
this book so that you can create Python
1:13
you can practice Python okay so there
1:14
are a lot of topics that this ebook
1:16
cover okay but this is more recommended
1:19
for beginners beginners in Python or for
1:21
those who starting learning Python
1:22
itself so there are a lot of exercise
1:25
that you can uh solve you can go through
1:28
this okay the most of exercise they it
1:30
has some of flow chart so that will help
1:32
you to understand the program and to
1:34
build your logical thinking so apart of
1:36
that this same ebook okay there are kind
1:39
of tips that will help you okay to
1:40
remember about some Python topics that
1:43
you can use while solving this same
1:46
problem uh the same exercise so there
1:48
are a lot of exercise okay more than 30
1:50
exercise as you can see most of them it
1:52
has kind of different problem different
1:54
of challenge okay so you can solve you
1:58
can practice Python by solving this same
2:00
exercise so I'll keep the link of this
2:03
ebook okay in the description in the
2:05
description of this video so that you
2:06
can go grab it and enjoy solving
2:09
problems there okay perfect so this is
2:13
our thing that we need to calculate we
2:15
need to solve okay a program that can
2:17
help us calculate this thing so this is
2:19
the program from the previous exercise
2:22
okay just let me create a new one i'm
2:24
going to come here as always let me say
2:27
exercise okay
2:32
exercise_03 okay
2:36
dotp and then let me hide this and uh
2:40
come down and let's start solving the
2:43
things here okay close these guys close
2:44
this guy i don't need them i only need
2:46
this one okay let me close this a little
2:49
bit and boom so that I can have this and
2:53
I can see also the formula okay because
2:54
I need to know the value of the pi so
2:56
this 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
3:20
program to calculate the area of this
3:23
guy boom come here boom solve and they
3:26
come here little space come here boom a
3:29
little
3:33
space okay perfect so then after this so
3:35
the next thing that we need to do will
3:37
be something like this okay uh let's
3:40
first read the program okay get the flow
3:42
shot so that we can understand what we
3:43
are 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
4:11
into r into r okay so it can be
4:16
something like this or here we have some
4:18
the formula of area okay r is equal
4:20
p into r boom boom boom okay
4:23
something like this so in Python in
4:26
order to do this okay we can do stuff
4:31
like okay if I yeah we can do something
4:33
like this okay by two so that mean this
4:37
this means are okay in power two perfect
4:43
so then we need the message so the
4:45
message I'm going to do print open and
4:46
close so here inside I'm going to say
4:48
okay what I'm going to print I'm going
4:50
to print the area as they say show area
4:52
so that's why I'm say print area perfect
4:55
now save so the next step now let me
4:59
give the values okay so here I put R but
5:02
it's not R here I use it radius okay so
5:05
I'm going to copy this guy come here and
5:07
boom save change okay radius radius so
5:10
now for the pi I don't have this
5:12
variable so let me create the pi so pi
5:15
will be equal uh what's the value of the
5:18
pi
5:18
3.2
5:22
3.14 okay uh just let let's keep only
5:24
one for is enough and know that it's
5:26
long it keep just going on going on keep
5:28
like this perfect
5:30
save so now we have all the values so
5:33
now let me try to execute this and to
5:35
see what's going to happen save and if I
5:37
run this come a little up what say he
5:41
gave us
5:42
78.5 wow what a fun is this
5:46
okay yeah okay uh this is correct okay
5:50
let me try radius radius so instead of a
5:53
radius I'm just going to give a big R
5:55
itself so that will be like a radius
5:59
this also be like big R radius perfect
6:05
save then if uh let me close this let me
6:08
run
6:09
again 78 okay okay and if the radius of
6:15
this is like 100 safe and if I run
6:23
again and tree blah blah blah blah blah
6:25
blah okay perfect I see I don't
6:27
understand anything about geometry okay
6:30
so I don't know if there is correct or
6:34
not but I don't understand anything
6:35
about geometry but I think okay it's
6:37
correct but okay this R is not make is
6:40
making me kind of confused let me put R
6:43
okay into
6:45
oh R into R something like this
6:50
okay save and if I run this ah perfect
6:54
okay okay the same thing perfect so now
6:57
let's try to change the program okay
6:58
because we don't need like to give a
7:00
fixed number okay as always so let's use
7:02
input so instead of 100 uh since this is
7:05
a 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
7:14
input input open and close and let me do
7:18
something okay boom enter
7:22
the 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:50
radius of the
7:53
circle is is what uh open and close i'm
7:59
going to use what area not the radius
8:02
the area of the circle the area okay the
8:06
area of the circle is blah blah blah
8:09
like this i'm going to give the area
8:11
okay then I'm going to save so if I run
8:14
this
8:15
again and come a little up and I will
8:19
enter the radius of circle F if I give
8:22
10 boom what is going to give so the
8:25
area of the circle is
8:28
314 okay 0 so this is how you can solve
8:33
okay one of the way not this is how you
8:35
can solve but this is one of the way
8:37
that you can solve okay as I always say
8:39
okay there is a lot of way that you can
8:41
solve this same problem okay so this is
8:42
one of the way that I found but for sure
8:45
you will find a different way which is
8:47
also a better way okay so you can change
8:49
you can modify this same program okay
8:51
you can make it look good okay so this
8:55
is 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
#Programming

