{ "metadata": { "name": "ex.3" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# \u4e60\u98983: \u6570\u5b57\u548c\u6570\u5b66\u8ba1\u7b97" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
+\u52a0\u53f7plus
-\u51cf\u53f7minus
/\u659c\u6760slash
*\u661f\u53f7asterisk
%\u767e\u5206\u53f7percent
<\u5c0f\u4e8e\u53f7less-than
>\u5927\u4e8e\u53f7greater-than
<=\u5c0f\u4e8e\u7b49\u4e8e\u53f7less-than-equal
>=\u5927\u4e8e\u7b49\u4e8e\u53f7greater-than-equal
" ] }, { "cell_type": "code", "collapsed": false, "input": [ "print \"I will now count my chickens:\"\n", "\n", "print \"Hens\", 25 + 30 / 6\n", "print \"Roosters\", 100 - 25 * 3 % 4\n", "\n", "print \"Now I will count the eggs:\"\n", "\n", "print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6\n", "\n", "print \"Is it true that 3 + 2 < 5 - 7?\"\n", "\n", "print 3 + 2 < 5 - 7\n", "\n", "print \"What is 3 + 2?\", 3 + 2\n", "print \"What is 5 - 7?\", 5 - 7\n", "\n", "print \"Oh, that's why it's False.\"\n", "\n", "print \"How about some more.\"\n", "\n", "print \"Is it greater?\", 5 > -2\n", "print \"Is it greater or equal?\", 5 >= -2\n", "print \"Is it less or equal?\", 5 <= -2" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "I will now count my chickens:\n", "Hens 30\n", "Roosters 97\n", "Now I will count the eggs:\n", "7\n", "Is it true that 3 + 2 < 5 - 7?\n", "False\n", "What is 3 + 2? 5\n", "What is 5 - 7? -2\n", "Oh, that's why it's False.\n", "How about some more.\n", "Is it greater? True\n", "Is it greater or equal? True\n", "Is it less or equal? False\n" ] } ], "prompt_number": 1 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## \u6d6e\u70b9\u6570" ] }, { "cell_type": "code", "collapsed": false, "input": [ "print 5 / 2\n", "print 5.0 / 2.0\n", "print 5 / 2.0\n", "print 5 / (2 * 1.)\n", "print float(5) / 2\n", "print int(5.0) / 2" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "2\n", "2.5\n", "2.5\n", "2.5\n", "2.5\n", "2\n" ] } ], "prompt_number": 2 } ], "metadata": {} } ] }