Geometry

Save all functions into the same file named geometry.py. All functions must return type float values.

  1. Write the function area_perim_circle() that given the radius of a circle returns the perimeter and the area.

    Examples:

    >>> a,p = area_perim_circle(0.3)
    >>> round(a,4)
    0.2827
    >>> round(p,4)
    1.885
    
    >>> a,p = area_perim_circle(1.57)
    >>> round(a,4)
    7.7437
    >>> round(p,4)
    9.8646
    

    Note

    You can download the file with tests area_perim_circle.txt.

  2. Write the function area_volum_sphere() that given the radius of a sphere returns the area and the volume.

    Examples:

    >>> a,v = area_volum_sphere(1)
    >>> round(a,4)
    12.5664
    >>> round(v,4)
    4.1888
    
    >>> a,v = area_volum_sphere(1.57)
    >>> round(a,4)
    30.9748
    >>> round(v,4)
    16.2102
    

    Note

    You can download the file with tests area_volum_sphere.txt.

  3. Write the function perim_area_rectangle() that given the lenght of the base and the height of a rectangle returns the perimeter and the area.

    Examples:

    >>> p,a = perim_area_rectangle(36.34,13.25)
    >>> round(p,2)
    99.18
    >>> round(a,2)
    481.51
    
    >>> p,a = perim_area_rectangle(5,3)
    >>> round(p,2)
    16.0
    >>> round(a,2)
    15.0
    

    Note

    You can download the file with tests perim_area_rectangle.txt.

  4. Write a function that given the lenght of two legs of a right-angled triangle returns the lenght of the hypotenuse.

  5. Write a function that given the lenght of the hypotenuse of a right-angled triangle and one of the not right angles in radians, returns the lenght of the two legs.

  6. Write a function that given the lenght of the hypotenuse of a right-angled triangle and the value in degrees of one of the not right angles, returns the lenght of the two legs.

Solution

A solution of these functions is provided in the geometry.py file.