We want to calculate the circumference and area of a circle given its radius.
To create the program, we need to do a couple of things:
A natural number (\(\mathbb{N}\)).
A line of text that defines the circumference and area.
The circumference is {circumference} and the area is {area}
What is the circumference and area of a circle of radius 2? The input is marked in bold.
Enter the radius of your circle: 2
The circumference is 12.566370614359172 and the area is 12.566370614359172
Formulas
The relevant mathematical formulas are:
\(\textrm{circumference} = 2 * \textrm{radius} * \pi\)
\(\textrm{area} = \textrm{radius}^2 * \pi\)
Read number in Python
To read a number into Python, use the
input()
function. That function will read in the user input and save it as text. You can then use theint()
function to convert the text from earlier into an integer.