Random Circle Area Generator

  • Share this:

Code introduction


This function generates a random area of a circle with a given radius within a certain range.


Technology Stack : math library (mathematical functions), random library (random number generation)

Code Type : Function

Code Difficulty : Intermediate


                
                    
import math
import random

def generate_random_circle_area(radius=1):
    """
    Generate a random area of a circle with a given radius.
    """
    return math.pi * (random.uniform(0.5, 1.5) * radius ** 2)