{ "metadata": { "name": "ex.5" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# \u4e60\u98985: \u66f4\u591a\u7684\u53d8\u91cf\u548c\u6253\u5370\n", "\n", "> \u5b57\u7b26\u4e32\u662f\u975e\u5e38\u597d\u7528\u7684\u4e1c\u897f\uff0c\u6240\u4ee5\u518d\u8fd9\u4e2a\u7ec3\u4e60\u4e2d\u4f60\u5c06\u5b66\u4f1a\u5982\u4f55\u521b\u5efa\u5305\u542b\u53d8\u91cf\u5185\u5bb9\u7684\u5b57\u7b26\u4e32\u3002\u4f7f\u7528\u4e13\u95e8\u7684\u683c\u5f0f\u548c\u8bed\u6cd5\u628a\u53d8\u91cf\u7684\u5185\u5bb9\u653e\u5230\u5b57\u7b26\u4e32\u91cc\uff0c\u76f8\u5f53\u4e8e\u6765\u544a\u8bc9 python \uff1a\u201c\u563f\uff0c\u8fd9\u662f\u4e00\u4e2a\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\uff0c\u628a\u8fd9\u4e9b\u53d8\u91cf\u653e\u5230\u90a3\u51e0\u4e2a\u4f4d\u7f6e\u3002\u201d" ] }, { "cell_type": "code", "collapsed": false, "input": [ "my_name = 'Zed A. Shaw'\n", "my_age = 35 # not a lie\n", "my_height = 74 # inches\n", "my_weight = 180 # lbs\n", "my_eyes = 'Blue'\n", "my_teeth = 'White'\n", "my_hair = 'Brown'\n", "\n", "print \"Let's talk about %s.\" % my_name\n", "print \"He's %d inches tail.\" % my_height\n", "print \"He's %d pounds heavy.\" % my_weight\n", "print \"Actually that's not too heavy.\"\n", "print \"He's got %s eyes and %s hair.\" % (my_eyes, my_hair)\n", "print \"His teeth are usually %s depending on the coffee.\" % my_teeth\n", "\n", "# this line is tricky, try to get it exactly right\n", "print \"If I add %d, %d, and %d I get %d.\" % (\n", " my_age, my_height, my_weight, my_age + my_height + my_weight)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Let's talk about Zed A. Shaw.\n", "He's 74 inches tail.\n", "He's 180 pounds heavy.\n", "Actually that's not too heavy.\n", "He's got Blue eyes and Brown hair.\n", "His teeth are usually White depending on the coffee.\n", "If I add 35, 74, and 180 I get 289.\n" ] } ], "prompt_number": 1 } ], "metadata": {} } ] }