Created
February 26, 2019 16:43
-
-
Save yv84/5422c68dc7aba062ce72f97a9d362890 to your computer and use it in GitHub Desktop.
для_ирины
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 18, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "class Морковка:\n", | |
| " def __init__(self):\n", | |
| " self.x = \"морковка\"\n", | |
| " def __repr__(self):\n", | |
| " return self.x\n", | |
| " def __str__(self):\n", | |
| " return self.__repr__()\n", | |
| " \n", | |
| "\n", | |
| "class Мясо:\n", | |
| " def __init__(self):\n", | |
| " self.x = \"мясо\"\n", | |
| " def __repr__(self):\n", | |
| " return self.x\n", | |
| " def __str__(self):\n", | |
| " return self.__repr__()\n", | |
| "\n", | |
| "class Лук:\n", | |
| " def __init__(self):\n", | |
| " self.x = \"лук\"\n", | |
| " def __repr__(self):\n", | |
| " return self.x\n", | |
| " def __str__(self):\n", | |
| " return self.__repr__()\n", | |
| " \n", | |
| "class Суп:\n", | |
| " def __init__(self):\n", | |
| " self.морковка = Морковка()\n", | |
| " self.мясо = Мясо()\n", | |
| " self.лук = Лук()\n", | |
| " self.status = \"Я не готов еще\"\n", | |
| " \n", | |
| " def приготовить(self):\n", | |
| " self.status = \"Я уже готов\"\n", | |
| " \n", | |
| " def __repr__(self):\n", | |
| " return self.status + \". Я состою из \" + str(self.морковка) + \", \" + str(self.мясо) + \", \" + str(self.лук)\n", | |
| "\n" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 19, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Я не готов еще. Я состою из морковка, мясо, лук\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "суп = Суп()\n", | |
| "print(суп)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 20, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Я уже готов. Я состою из морковка, мясо, лук\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "суп.приготовить()\n", | |
| "print(суп)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "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.7.1" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 2 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment