{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "120\n" ] } ], "source": [ "# Write a Python class named Rectangle constructed by a length and width and a method which will compute the area of a rectangle.\n", "\n", "class Rectangle():\n", " def __init__(self, l, w):\n", " self.length = l\n", " self.width = w\n", "\n", " def rectangle_area(self):\n", " return self.length*self.width\n", "\n", "newRectangle = Rectangle(12, 10)\n", "\n", "print(newRectangle.rectangle_area())" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }