{ "metadata": { "name": "ex.4" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# \u4e60\u98984: \u53d8\u91cf\u548c\u547d\u540d\n", "\n", "\u53d8\u91cf\u662f\u7528\u6765\u6307\u4ee3\u67d0\u79cd\u4e1c\u897f(\u5b57\u7b26\u4e32, \u6570\u5b57, \u51fd\u6570\u7b49\u7b49)\u7684\u540d\u5b57. \u597d\u7684\u53d8\u91cf\u540d\u53ef\u4ee5\u8ba9\u7a0b\u5e8f\u66f4\u52a0\u5bb9\u6613\u7406\u89e3." ] }, { "cell_type": "code", "collapsed": false, "input": [ "cars = 100\n", "space_in_a_car = 4.0\n", "drivers = 30\n", "passengers = 90\n", "cars_not_driven = cars - drivers\n", "cars_driven = drivers\n", "carpool_capacity = cars_driven * space_in_a_car\n", "average_passengers_per_car = passengers / cars_driven\n", "\n", "\n", "print \"There are\", cars, \"cars avaiable.\"\n", "print \"There are only\", drivers, \"drivers avaiable.\"\n", "print \"There will be\", cars_not_driven, \"empty cars today.\"\n", "print \"We can transport\", carpool_capacity, \"people today.\"\n", "print \"We have\", passengers, \"to carpool today.\"\n", "print \"We need to put about\", average_passengers_per_car, \"in each car.\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "There are 100 cars avaiable.\n", "There are only 30 drivers avaiable.\n", "There will be 70 empty cars today.\n", "We can transport 120.0 people today.\n", "We have 90 to carpool today.\n", "We need to put about 3 in each car.\n" ] } ], "prompt_number": 1 }, { "cell_type": "markdown", "metadata": {}, "source": [ "* \u7f16\u7801\u98ce\u683c: \u6ce8\u610f`=`\u4e24\u8fb9\u7684\u7a7a\u683c.\n", "* \u53bb\u6389\u8f93\u51fa\u4e2d\u7684\u7a7a\u683c:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "print \"Hey %s there.\" % \"you\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Hey you there.\n" ] } ], "prompt_number": 2 } ], "metadata": {} } ] }