In the previous article, we have discussed Python Program for Area of a Circumscribed Circle of a Square
Given the radius of the circle, the task is to calculate the area of a square circumscribed by the circle.
Formula:
The formula to find the area of a square circumscribed by the circle = 2*(radius**2)
Where ** indicates power value
Examples:
Example1:
Input:
Given radius = 8
Output:
The area of a square circumscribed by the circle for the given radius{ 8 } = 128
- Python Program for Area of a Circumscribed Circle of a Square
- Python Program for Volume and Surface Area of Frustum of Cone
- Python Program to Calculate Volume of Ellipsoid
Example2:
Input:
Given radius = 5
Output:
The area of a square circumscribed by the circle for the given radius{ 5 } = 50
Program for Area of Square Circumscribed by Circle in Python
Below are the ways to calculate the area of a square circumscribed by the circle in Python:
Method #1: Using Mathematical Formula (Static Input)
Approach:
- Give the radius as static input and store it in a variable.
- Create a function to say Areacircumscribd_square() which takes the given radius of the circle as an argument, and returns the area of a square circumscribed by the circle.
- Inside the function, calculate the area of a square circumscribed by the circle using the above mathematical formula and store it in a variable.
- Return the above result.
- Pass the given radius as an argument to the Areacircumscribd_square() function and store it in another variable.
- Print the above result by rounding off to the 2 places after the decimal point using the round() function.
- The Exit of the Program.
Below is the implementation:
# Create a function to say Areacircumscribd_square() which takes the given radius of # the circle as an argument, and returns the area of a square circumscribed # by the circle. def Areacircumscribd_square(gvn_radiuss): # Inside the function, calculate the area of a square circumscribed by the circle # using the above mathematical formula and store it in a variable. area_squar = (2 * gvn_radiuss * gvn_radiuss) # Return the above result. return area_squar # Give the radius as static input and store it in a variable. gvn_radiuss = 8 # Pass the given radius as an argument to the Areacircumscribd_square() function and # store it in another variable. fnl_rsltarea = Areacircumscribd_square(gvn_radiuss) # Print the above result by rounding off to the 2 places after the decimal point # using the round() function. print("The area of a square circumscribed by the circle for the given radius{", gvn_radiuss, "} = ", round( fnl_rsltarea, 2))
Output:
The area of a square circumscribed by the circle for the given radius{ 8 } = 128
Method #2: Using Mathematical Formula (User Input)
Approach:
- Give the radius as user input using the float(input()) function and store it in a variable.
- Create a function to say Areacircumscribd_square() which takes the given radius of the circle as an argument, and returns the area of a square circumscribed by the circle.
- Inside the function, calculate the area of a square circumscribed by the circle using the above mathematical formula and store it in a variable.
- Return the above result.
- Pass the given radius as an argument to the Areacircumscribd_square() function and store it in another variable.
- Print the above result by rounding off to the 2 places after the decimal point using the round() function.
- The Exit of the Program.
Below is the implementation:
# Create a function to say Areacircumscribd_square() which takes the given radius of # the circle as an argument, and returns the area of a square circumscribed # by the circle. def Areacircumscribd_square(gvn_radiuss): # Inside the function, calculate the area of a square circumscribed by the circle # using the above mathematical formula and store it in a variable. area_squar = (2 * gvn_radiuss * gvn_radiuss) # Return the above result. return area_squar # Give the radius as user input using the float(input()) function and store it in a variable. gvn_radiuss = float(input("Enter some random number = ")) # Pass the given radius as an argument to the Areacircumscribd_square() function and # store it in another variable. fnl_rsltarea = Areacircumscribd_square(gvn_radiuss) # Print the above result by rounding off to the 2 places after the decimal point # using the round() function. print("The area of a square circumscribed by the circle for the given radius{", gvn_radiuss, "} = ", round( fnl_rsltarea, 2))
Output:
Enter some random number = 5 The area of a square circumscribed by the circle for the given radius{ 5.0 } = 50.0
Find the best practical and ready-to-use Python Programming Examples that you can simply run on a variety of platforms and never stop learning.
- Python Program for Pizza Cut Problem (Or Circle Division by Lines)
- Python Program to Check If a Line Touches or Intersects a Circle
- Python Program to Check if a given Circle lies Completely Inside the Ring formed by Two Concentric Circles
- Python Program for Area of a Circumscribed Circle of a Square