Exercise: Script Explanation with OpenAI
Test the concepts we’ve learned with a coding exercise.
We'll cover the following
Problem statement
In this exercise, develop a straightforward Python script for fundamental geometry computations using the GeometryCalculator
class. Additionally, incorporate a function named explain_script
that employs ChatGPT to articulate a natural language description of the script’s intent.
Coding challenge
Implement a Python class named
GeometryCalculator
featuring the subsequent methods:area_of_circle(radius)
: Compute the area of a circle.perimeter_of_square(side_length)
: Compute the perimeter of a square.
Construct a function named
explain_script
that utilizes ChatGPT to provide a coherent, natural language elucidation of the script’s purpose. This explanation should encompass the function of theGeometryCalculator
class and its methods.Showcase the application of the
GeometryCalculator
class by initializing an instance, conducting geometric calculations, and invoking theexplain_script
function.
Get hands-on with 1400+ tech skills courses.