ex24更多练习

很简单,贴代码

#coding=utf-8
print "Let's practice everything."
print 'You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.'

poem = """
\t The lovely world
with logic so firmly planted
cannot discern \n the needs of lovely
nor comprehend passion from intution
and requires an explanation
\n\t\twhere there is none.
"""

print "--------------"
print poem
print "--------------"

five = 10 - 2 + 3 -6
print "This should be five: %s" % five

def secret_formula(started):
    jelly_beans = started * 500
    jars = jelly_beans / 1000
    crates = jars / 100
    return jelly_beans, jars, crates

start_point = 10000
beans, jars, crates = secret_formula(start_point)

print "With s starting point of : %d" % start_point
print "We'd have %d beans, %d jars, and %d crates." % (beans, jars, crates)

start_point = start_point / 10

print "We can also do that this way:"
print "We'd have %d beans,%d jars, and %d crates" % secret_formula(start_point)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,676评论 25 709
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,301评论 4 61
  • 去年这个时候在家呆的郁闷 考完试的空虚和想出去打工无所事事 想出去走走没资本内心的焦灼滋味 火气大到可怕 给隔壁小...
    月下子蟹阅读 183评论 0 0
  • 本文预览: 状态模式 组合模式 迭代器 职责链 命令 状态模式 定义:状态模式(State Pattern),允许...
    alex_zhou阅读 337评论 0 0
  • 每天清晨, 老爷爷都带着他的手风琴来, 我想, 他一定有很多故事 是春,是夏,是秋,还是 冬 他,以前是个文艺的才...
    皇上微醺阅读 433评论 3 7