{
    "componentChunkName": "component---src-templates-challenges-projects-frontend-show-tsx",
    "path": "/learn/scientific-computing-with-python/scientific-computing-with-python-projects/polygon-area-calculator",
    "result": {"data":{"challengeNode":{"challenge":{"forumTopicId":462363,"title":"Polygon Area Calculator","description":"<section id=\"description\">\n<p>You will be working on this project with our Replit starter code.</p>\n</section>","instructions":"<section id=\"instructions\">\n<p>In this project you will use object oriented programming to create a Rectangle class and a Square class. The Square class should be a subclass of Rectangle and inherit methods and attributes.</p>\n<h2>Rectangle class</h2>\n<p>When a Rectangle object is created, it should be initialized with <code>width</code> and <code>height</code> attributes. The class should also contain the following methods:</p>\n<ul>\n<li><code>set_width</code></li>\n<li><code>set_height</code></li>\n<li><code>get_area</code>: Returns area (<code>width * height</code>)</li>\n<li><code>get_perimeter</code>: Returns perimeter (<code>2 * width + 2 * height</code>)</li>\n<li><code>get_diagonal</code>: Returns diagonal (<code>(width ** 2 + height ** 2) ** .5</code>)</li>\n<li><code>get_picture</code>: Returns a string that represents the shape using lines of \"*\". The number of lines should be equal to the height and the number of \"*\" in each line should be equal to the width. There should be a new line (<code>\\n</code>) at the end of each line. If the width or height is larger than 50, this should return the string: \"Too big for picture.\".</li>\n<li><code>get_amount_inside</code>: Takes another shape (square or rectangle) as an argument. Returns the number of times the passed in shape could fit inside the shape (with no rotations). For instance, a rectangle with a width of 4 and a height of 8 could fit in two squares with sides of 4.</li>\n</ul>\n<p>Additionally, if an instance of a Rectangle is represented as a string, it should look like: <code>Rectangle(width=5, height=10)</code></p>\n<h2>Square class</h2>\n<p>The Square class should be a subclass of Rectangle. When a Square object is created, a single side length is passed in. The <code>__init__</code> method should store the side length in both the <code>width</code> and <code>height</code> attributes from the Rectangle class.</p>\n<p>The Square class should be able to access the Rectangle class methods but should also contain a <code>set_side</code> method. If an instance of a Square is represented as a string, it should look like: <code>Square(side=9)</code></p>\n<p>Additionally, the <code>set_width</code> and <code>set_height</code> methods on the Square class should set both the width and height.</p>\n<h2>Usage example</h2>\n<pre><code class=\"language-py\">rect = shape_calculator.Rectangle(10, 5)\nprint(rect.get_area())\nrect.set_height(3)\nprint(rect.get_perimeter())\nprint(rect)\nprint(rect.get_picture())\n\nsq = shape_calculator.Square(9)\nprint(sq.get_area())\nsq.set_side(4)\nprint(sq.get_diagonal())\nprint(sq)\nprint(sq.get_picture())\n\nrect.set_height(8)\nrect.set_width(16)\nprint(rect.get_amount_inside(sq))\n</code></pre>\n<p>That code should return:</p>\n<pre><code class=\"language-bash\">50\n26\nRectangle(width=10, height=3)\n**********\n**********\n**********\n\n81\n5.656854249492381\nSquare(side=4)\n****\n****\n****\n****\n\n8\n</code></pre>\n<p>The unit tests for this project are in <code>test_module.py</code>.</p>\n<h2>Development</h2>\n<p>Write your code in <code>shape_calculator.py</code>. For development, you can use <code>main.py</code> to test your <code>shape_calculator()</code> function. Click the \"run\" button and <code>main.py</code> will run.</p>\n<h2>Testing</h2>\n<p>We imported the tests from <code>test_module.py</code> to <code>main.py</code> for your convenience. The tests will run automatically whenever you hit the \"run\" button.</p>\n<h2>Submitting</h2>\n<p>Copy your project's URL and submit it to freeCodeCamp.</p>\n</section>","challengeType":10,"helpCategory":"Python","superBlock":"scientific-computing-with-python","certification":"scientific-computing-with-python","block":"scientific-computing-with-python-projects","translationPending":false,"fields":{"blockName":"Scientific Computing with Python Projects","slug":"/learn/scientific-computing-with-python/scientific-computing-with-python-projects/polygon-area-calculator"}}}},"pageContext":{"challengeMeta":{"certification":"scientific-computing-with-python","superBlock":"scientific-computing-with-python","block":"scientific-computing-with-python-projects","template":null,"required":[],"nextChallengePath":"/learn/scientific-computing-with-python/scientific-computing-with-python-projects/probability-calculator","prevChallengePath":"/learn/scientific-computing-with-python/scientific-computing-with-python-projects/budget-app","id":"5e444147903586ffb414c94f"},"projectPreview":{"showProjectPreview":false,"challengeData":{"challengeType":10,"challengeFiles":[]}},"slug":"/learn/scientific-computing-with-python/scientific-computing-with-python-projects/polygon-area-calculator"}},
    "staticQueryHashes": ["3216307819","3851966407"]}