#!/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. git把本地代码上传(更新)到github上

    # 初始化目录为本地仓库 git init # 添加所有文件到暂存去 git add . # 提交所有文件 git commit -m "init" # 添加远程仓库地址 git ...

  2. 基于 Python 的自定义分页组件

    基于 Python 的自定义分页组件 分页是网页中经常用到的地方,所以将分页功能分出来,作为一个组件可以方便地使用. 分页实际上就是不同的 url ,通过这些 url 获取不同的数据. 业务逻辑简介 ...

  3. 一条sql引发的“血案”

    前几天有一个项目要上线,需要对表的一个字段进行扩充,项目经理让我准备脚本,于是我准备了如下的脚本: )); )); )); 结果上线的时候,ord_log1和ord_log2表中有30万数据,在执行的 ...

  4. 安装FaaS

    [root@localhost ~]# [root@localhost ~]# new OS:centos-7 [root@localhost ~]# [root@localhost ~]# vim ...

  5. 搭建Keepalived+LNMP架构web动态博客 实现高可用与负载均衡

    环境准备: 192.168.193.80  node1 192.168.193.81 node2 关闭防火墙 [root@node1 ~]# systemctl stop firewalld #两台都 ...

  6. This page includes a password or credit card input in a non-secure context. A warning has been added

    此页面包含非安全上下文中的密码或信用卡输入.URL栏中添加了一个警告.有关更多信息,请参阅https://goo.gl/zmWq3m. 因为你的页面里面有input type是password,谷歌浏 ...

  7. tf.cast()用法

    把布尔类型转化成0和1类型,true是1,false是0反之,亦成立.

  8. ELK windows下部署测试

    操作系统 win7 (当时想在linux下部署,虚拟内存过小,转而在windows下) 版本说明 elasticsearch-6.6.2  (elasticsearch-head-master插件) ...

  9. 【LGR-062】洛谷10月月赛 III div.2 (A-C)

    前言 100+100+46+0=246pts 300多名 以后每次比赛都要有进步哦!qwq 小D与笔试 水题 Code #include<algorithm> #include<io ...

  10. 前端学习记录(HTML篇)

    HTML Hyper Text Markup Language,超文本标记语言,不是一种编程语言,而是一种标记语言 思想:网页中有很多数据,不同的数据可能需要不同的显示效果,一个标签相当于一个容器,想 ...