#!/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. vmware 中标麒麟系统安装VM tools

    打开虚拟机系统,选择菜单虚拟机->安装VMware TOOLs,下载后找到文件. 我的文件名称是 VMwareTools-10.2.5-8068393.tar.gz, 在终端里输入:tar xv ...

  2. [Codeforces 1197E]Culture Code(线段树优化建图+DAG上最短路)

    [Codeforces 1197E]Culture Code(线段树优化建图+DAG上最短路) 题面 有n个空心物品,每个物品有外部体积\(out_i\)和内部体积\(in_i\),如果\(in_i& ...

  3. 手写ORM持久层框架(转)

    工程结构: 本文测试的数据库为: 其中student的表结构为: 表数据: 配置文件 DB2.properties driver=com.mysql.jdbc.Driver url=jdbc\:mys ...

  4. #10017 传送带(SCOI 2010)(三分套三分)

    [题目描述] 在一个 2 维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段 AB 和线段 CD.lxhgww 在 AB上的移动速度为 P ,在 CD 上的移动速度为 Q,在平 ...

  5. C#根据出生日期和当前日期计算精确年龄

    C#根据出生日期和当前日期计算精确年龄更多 0c#.net基础 public static string GetAge(DateTime dtBirthday, DateTime dtNow){ st ...

  6. 深入理解js闭包【写的通俗易懂,很值的阅读】

    详细内容在下面这个链接里面: https://www.cnblogs.com/uedt/archive/2010/10/28/1863389.html 能写出这样的文章,定是大佬!

  7. ASE Beta Sprint - backend scrum 4

    本次scrum于2019.12.10在sky garden进行,持续10分钟. 参与人: Xin Kang, Zhikai Chen, Lihao Ran, Hao Wang 请假: Ning Jia ...

  8. nginx报错[error] CreateFile() "D:\Java-windows\nginx-1.16.0/logs/nginx.pid" failed (2: The system cannot find the file specified)

    无论是nginx -s stop还是nginx -s reload命令,都会出现这个错误. 解决方法:使用命令创建/logs/nginx.pid文件,命令如下所示: nginx -c conf/ngi ...

  9. 尖沙咀到底谁说的算?!--- CSS层叠

    前些天,我朋友发了这个段CSS我. //css *{ color:#fff ; } div{ color:#000 !important; } //html <div><span&g ...

  10. postgres - 以单用户模式运行一个 PostgreSQL服务器

    SYNOPSIS postgres [ -A 0 | 1] [ -B nbuffers] [ -c name=value] [ -d debug-level] [ --describe-config ...