{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "200.96\n", "50.24\n" ] } ], "source": [ "# Write a Python class named Circle constructed by a radius and two methods which\n", "# will compute the area and the perimeter of a circle.\n", "\n", "class Circle():\n", " def __init__(self, r):\n", " self.radius = r\n", "\n", " def area(self):\n", " return self.radius**2*3.14\n", " \n", " def perimeter(self):\n", " return 2*self.radius*3.14\n", "\n", "NewCircle = Circle(8)\n", "print(NewCircle.area())\n", "print(NewCircle.perimeter())" ] } ], "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 }