{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2018-01-23T17:45:41.624086Z", "start_time": "2018-01-23T17:45:41.611872Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hello World\n" ] } ], "source": [ "print \"Hello World\"" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "ExecuteTime": { "end_time": "2018-01-23T17:51:05.011006Z", "start_time": "2018-01-23T17:51:04.990473Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(5 - 6) = -1\n", " 8 * 9 = 72\n", " 6 / 2 = 3\n", " 5 / 2 = 2\n", " 5.0 / 2 = 2.5\n", " 5 % 2 = 1\n", " 2 * (10 + 3) = 26\n", " 2 ** 4 = 16\n" ] }, { "ename": "SyntaxError", "evalue": "unexpected EOF while parsing (, line 0)", "output_type": "error", "traceback": [ "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32munknown\u001b[0m\n\u001b[0;31m \u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m unexpected EOF while parsing\n" ] } ], "source": [ "def echoPrint(s):\n", " if s:\n", " print \"{} = {}\".format(s, eval(s))\n", "commands = \"\"\"\n", "(5 - 6)\n", " 8 * 9\n", " 6 / 2\n", " 5 / 2\n", " 5.0 / 2\n", " 5 % 2\n", " 2 * (10 + 3)\n", " 2 ** 4\n", " \"\"\"\n", "for command in commands.split('\\n'):\n", " echoPrint(command)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python [conda env:py27]", "language": "python", "name": "conda-env-py27-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.14" }, "latex_envs": { "bibliofile": "biblio.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 0 }, "nav_menu": {}, "toc": { "navigate_menu": true, "number_sections": true, "sideBar": true, "threshold": 6, "toc_cell": false, "toc_section_display": "block", "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }