#!/usr/bin/python
#coding:utf-8
from sys import exit def gold_room():
print "this room is full of gold. how much do you take?" next = raw_input(">>")
if "" in next or "" in next:
how_much = int(next)
else:
dead("man, learn to type a number") if how_much < 50:
print "nice,you're not greedy,you win"
exit(0)
else:
dead("you greedy bastard") def bear_room():
print "there is a bear here"
print "the bear has a bunch of honey"
print "the fat bear is in front of another door."
print "how are you going to move the bear?"
bear_moved = False while True:
next = raw_input(">>") if next == "take honey":
dead("the bear looks at you then slaps your face off")
elif next == "taunt bear" and not bear_moved:
print "the bear has moved from the door.you can go through it now"
bear_moved = True
elif next == "taunt bear" and bear_moved:
dead("the bear gets pissed off and chews your legs off")
elif next == "open door" and bear_moved:
gold_room()
else:
print "I got no idea what that means" def cloth_room():
print "here you see the great evil cthulhu"
print "he , it,whatever stares at you and you go insane"
print "do you flee for your life or eat your head?" next = raw_input(">>") if "flee" in next:
start()
elif "head" in next:
dead("well that was tasty")
else:
cloth_room() def dead(why):
print why,"good job"
exit(0) def start():
print "you are in a dark room"
print "there is a door to your left and right"
print "which one do you take?" next = raw_input(">>") if next == "left":
bear_room()
elif next == "right":
cloth_room()
else:
dead("you stumble around the room until you starve") start()

相关函数:

Python List append()方法

Learn Python the hard way, ex35 分支和函数的更多相关文章

  1. [IT学习]Learn Python the Hard Way (Using Python 3)笨办法学Python3版本

    黑客余弦先生在知道创宇的知道创宇研发技能表v3.1中提到了入门Python的一本好书<Learn Python the Hard Way(英文版链接)>.其中的代码全部是2.7版本. 如果 ...

  2. 笨办法学 Python (Learn Python The Hard Way)

    最近在看:笨办法学 Python (Learn Python The Hard Way) Contents: 译者前言 前言:笨办法更简单 习题 0: 准备工作 习题 1: 第一个程序 习题 2: 注 ...

  3. 学 Python (Learn Python The Hard Way)

    学 Python (Learn Python The Hard Way) Contents: 译者前言 前言:笨办法更简单 习题 0: 准备工作 习题 1: 第一个程序 习题 2: 注释和井号 习题 ...

  4. 《Learn python the hard way》Exercise 48: Advanced User Input

    这几天有点时间,想学点Python基础,今天看到了<learn python the hard way>的 Ex48,这篇文章主要记录一些工具的安装,以及scan 函数的实现. 首先与Ex ...

  5. python中列表和字典常用方法和函数

    Python列表函数&方法 Python包含以下函数: 序号 函数 1 cmp(list1, list2)比较两个列表的元素 2 len(list)列表元素个数 3 max(list)返回列表 ...

  6. Python 几个重要的内置函数

    所谓内置函数,就是在Python中被自动加载的函数,任何时候都可以用.内置函数,这意味着我们不必为了使用该函数而导入模块.不必做任何操作,Python 就可识别内置函数.在学习Python的过程中,有 ...

  7. 【python】dir(__builtins__)查看python中所用BIF(内置函数)

    dir(__builtins__)查看python中所用BIF(内置函数)

  8. Python核心编程读笔 10:函数和函数式编程

    第11章 函数和函数式编程 一 调用函数  1 关键字参数 def foo(x): foo_suite # presumably does some processing with 'x' 标准调用 ...

  9. 初学 Python(十二)——高阶函数

    初学 Python(十二)--高阶函数 初学 Python,主要整理一些学习到的知识点,这次是高阶函数. #-*- coding:utf-8 -*- ''''' 话说高阶函数: 能用函数作为参数的函数 ...

随机推荐

  1. 循环结构 :while

    循环结构 :while 循环四要素: 1.初始化条件 2.循环条件 3.循环体 4.迭代条件 格式: 1.初始化条件 while(2.循环条件){ 3.循环体 4.迭代条件 } public clas ...

  2. window.onload后跟函数 和跟函数名的区别【window.onload = asd() 和 window.onload = asd 】

    window.onload:页面加载完毕执行[DOM tree + 外部图片 + 资源] <script> function asd(){ return 10; } window.onlo ...

  3. appscan 历史版本下载

    https://www.cnblogs.com/hua198/p/11120916.html

  4. 正在连接localhost...无法打开到主机的连接。 在port 8080: 连接失败

      在cmd中用telnet连接tomcat,出现了"正在连接localhost...无法打开到主机的连接. 在port 8080: 连接失败"原因是我的tomcat是绿色版的,没 ...

  5. 如何在springboot中读取自己创建的.properties配置的值

    在实体类里面加上 @PropertySource("classpath:/robot_config.properties") robot_config.properties // ...

  6. Ext.js性能优化漫谈

    Ext.js是一个用于建立企业级应用的纯JS框架.毫无疑问,它为我们提供了大量的组件,比如container,panel,field,grid,这些组件使用起来很方便,不需要去写js和html,但是e ...

  7. 数据写入到Excel,模板样式复杂

    先整理好Excel模板,如: 接下来在程序获取上面整理好的Excel模板并替换关键字就可以了public ActionResult SummaryStatistics() public ActionR ...

  8. 【杂记】mysql 左右连接查询中的NULL的数据筛选问题,查询NULL设置默认值,DATE_FORMAT函数

    MySQL左右连接查询中的NULL的数据筛选问题 xpression 为 Null,则 IsNull 将返回 True:否则 IsNull 将返回 False. 如果 expression 由多个变量 ...

  9. 10.Linux-CentOS系统重启之后Xshell无法SSH连接(云环境)

    问题:云环境下CentOS系统断电或强制关机,再开机出现问题:Entering emergency mode. Exit the shell to continue. Generating " ...

  10. js格式化数字或者小数,加入千分符(此次为”,“)

    function npChangeNum(num) { var tag = (num || 0).toString().split("."); tag[0] = tag[0].re ...