{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise 08 ##\n", "\n", "Create the following code using object oriented approach.\n", "\n", "* A person has a name.\n", "* A person may be a Student or a Professor.\n", "* A Student learn.\n", "* A Professor Researches and Teaches.\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "* Are the Politician honest? How is it possible changing the code so that Politician become honest?\n" ] }, { "cell_type": "code", "execution_count": 99, "metadata": {}, "outputs": [], "source": [ "class Citizen:\n", " def __init__(self, name):\n", " self.name=name\n", " self.__honest=True\n", "\n", "class Politician(Citizen):\n", " def speak(self):\n", " print(\"Bla Bla Bla\")\n", " def isHonest(self):\n", " print(self.__honest)\n", " \n", " \n", " " ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.7" } }, "nbformat": 4, "nbformat_minor": 4 }