上次进行到习题29,习题30中回答了之前29中给出问题的答案,以及强化了if语句使用,内容比较少,因此敲了一遍代码直接进行到习题31。

习题31,先上代码,从代码中可以发现作者不仅逗比,还挺吓人,喜欢写恐怖故事。

print "You enter a dark room with two doors.Do you go through the door #1 or door #2?"door = raw_input(">")if door == "1":print "There is a giant bear here eating a cheese cake. What do you do?"print "1.Take the cake."print "2. Scream at the bear."bear = raw_input(">")if bear =="1":print "The bear eats your face off. Good job!"elif bear =="2":print "The bear eats your legs off. Good job!"else:print "Well,doing %s is probably better.Bear runs away."elif door =="2":print "You stare into the endless abyss at Cthulhu's retina."print "1.Blueberries."print "2.Yellow jacket clothespins."print "3. Understanding revolvers yelling melodies."insanity = raw_input("> ")if insanity == "1" or insanity =="2":print "Your body survives powered by a mind of jello.Good job!"else:print "The insanity rots your eyes into a pool of muck.Good job!"else:print "You stumble around and fall on a knife and die.ood job!"

这个例子是一个小文字游戏,输入数字进入不同的故事章节。游戏有点吓人,不建议16周岁以下的宝宝玩,好怕怕,容易做噩梦。突然想到,昨天晚上做了一个噩梦,梦见和法老大战,怎么也杀不死,最后只能压在棺材里。哦,扯远了,还是回来接着学习吧,毕竟是学习笔记,不是日记,等有空重新开个博专心写日记。

这一部分主要是练习if嵌套if语句,让逻辑分支更丰满,也就更好玩。接下来进入加分习题。

---------------------------------------------------------------------------------------------------------------------------------------------------------

加分习题:为游戏添加新的部分,改变玩家做决定的位置。尽自己的能力扩展这个游戏,不过别把游戏弄得太怪异了。

What??!!加分习题竟然是添加新的部分,还不让把游戏弄得诡异??!已经很诡异了好么?这样画风难道让我变出个Hello Kitty消灭怪兽,然后和多啦A梦幸福快乐地生活在一起?

算了,毕竟还要跟着人家学python,忍忍就过去了。还是乖乖贴代码。

print "You enter a dark room with two doors.Do you go through the door #1 or door #2?"door = raw_input(">")if door == "1":print "There is a giant bear here eating a cheese cake. What do you do?"print "1.Take the cake."print "2.Scream at the bear."print "3.Run away immediately."bear = raw_input(">")if bear =="1":print "The bear eats your face off. Good job!"elif bear =="2":print "The bear eats your legs off. Good job!"elif bear == "3":print "You run into Doraemon!"print "1.Tell him that you could give dorayakis to him, if he kills the bear behind."print "2.Tell him that Hello Kitty is kidnapped by the bear behind."how_to_do = raw_input("> ")if how_to_do == "1":print "Doraemon has just eaten many dorayakis, he declines and goes away. Unfortunately, you will die."elif how_to_do =="2":print "To save the Hello Kitty, Doraemon kills the bear. However, you lie to him and he cuts your tonge as a punishment."else:print "Well,doing %s is probably better.Bear runs away."elif door =="2":print "You stare into the endless abyss at Cthulhu's retina."print "1.Blueberries."print "2.Yellow jacket clothespins."print "3. Understanding revolvers yelling melodies."insanity = raw_input("> ")if insanity == "1" or insanity =="2":print "Your body survives powered by a mind of jello.Good job!"else:print "The insanity rots your eyes into a pool of muck.Good job!"else:print "You stumble around and fall on a knife and die.ood job!"

新增加了碰到哆唻A梦的情节,反正都不是好结局,来啊,互相伤害啊。

笨方法学Python笔记(5)相关推荐

  1. 笨方法学Python笔记(6)

    在上一个博客中,我们已经学到了习题31,接下去是习题32关于list的联系,感觉自己好像已经掌握,就想偷懒直接跳过去,往后扫了几眼教程,一路扫到了文末,结尾是这样的一句话:"你会编程.他们不 ...

  2. 笨方法学python笔记(4)

    这几天做了布尔逻辑值的习题,按照书中的方法一步步进行记忆训练.由于这一部分记忆的东西比较多,不适合记录在博客上.目前进展到习题29,继续在博客上记录学习过程. 习题29的主题是if语句,老规矩,先贴敲 ...

  3. 笨方法学Python笔记(9)

    距离上次写的博客,已经过去一个多礼拜了,这一个多礼拜主要是做了习题37--阅读别人的代码.在Github上搜了一个抢票软件,于是沉迷其中不可自拔.前段时间杰伦演唱会,闺蜜在永乐上想抢票却失败了,据说是 ...

  4. 笨方法学Python笔记(7)

    下班了,可是本宝宝还要学习,沉迷学习不能自拔. 习题35:分支和函数 这一个习题的代码好长啊,敲得我手酸... from sys import exitdef gold_room():print &q ...

  5. 笔记 | 笨方法学Python

    整理 | 阿司匹林 出品 | 人工智能头条(公众号ID:AI_Thinker) Python 有多好应该不用多说了,毕竟它是"钦定的"最接近 AI 的语言.(当然,PHP 才是最好 ...

  6. 《 笨方法学 Python 》_ 目录

    < 笨方法学 Python >(第 3 版)书中代码是 Python 2 版本,本着学习 Python 3 的目的,用 Python 3 完成本书的习题,代码也已上传到 Github. 作 ...

  7. 笨方法学Python(二)

    笨方法学Python,习题16 - 21 版本:3.8.0 编辑器:Visual Studio Code 习题16到21讲的是文件的读写和函数的基础,可以通过一个实例来同时练习他们.在下列情景中,我将 ...

  8. 笨方法学python 习题37

    还是在笨方法学python中... 本节的习题是看一下作者列出的python中的各种运算符,尝试来理解这些符号. 在这里,我只列出了一些自己不会的,通过查百度得到得答案,这里来列举一下. (另外有不怎 ...

  9. 笨方法学python 15章疑问

    ** 笨方法学python 15章疑问 在15张中教我们读取文件,但是当我测试能否打开我之前写的py格式的文本时出现了这一幕 文件打开后然后又出现了 File "15.py", l ...

  10. 《笨方法学python》_《笨办法学Python》 第46课手记

    <笨办法学Python> 第46课手记 这节课制作了一个Python的项目骨架,花了我一个晚上和一个早上的时间,原因是我下载的pdf里面只有OX S的命令行,而没有win下的.我为此在知道 ...

最新文章

  1. 已知空间一点到另外两点直线的距离
  2. 找论文太难?试试这款「文本生成」论文搜索工具丨开源
  3. System Landscape Recommendations for SAP Customer Activity Repository
  4. 【 C 】字符串查找基础笔记
  5. Getting Installation aborted (Status 7) ApplyParsePerms: lsetfilecon of /syst...【转】
  6. ActiveMQ 消息持久化到Mysql数据库
  7. php课程---JavaScript与Jquery的区别(转)
  8. 分布式缓存管理与查询系统
  9. 机器学习/深度学习测试题(一) —— 单层感知器的激活函数
  10. 电脑如何查看x86与arm_电脑关联程序更改 如何更改电脑查看图片的方式
  11. Linq 学习笔记(一)
  12. QQBot:基于SmartQQ协议的QQ机器人
  13. 主流加密方式和工具比较
  14. 海克斯棋开源程序 FutaHex2 编译教程
  15. 终端应用安全之网络流量分析
  16. 【杂记】数据存储架构
  17. 试题 C: 数列求值
  18. 触发onclick事件元素的获取
  19. Android系统硬件访问服务框架分析
  20. 2019下半年中小学教资考试教育知识与能力试题(中学)——主观题

热门文章

  1. Unity3D编译器汉化
  2. 【学习笔记】软考中级【数据库系统工程师】下午题技巧
  3. 酷q机器人成语接龙插件_易语言开发酷Q机器人插件
  4. noVNC使用浏览器替代VNC客户端
  5. 用u盘刻录装服务器系统盘,光盘系统刻录到U盘上教程
  6. c语言判断sjis编码,loadrunner Web_类函数之web_sjis_to_euc_param()
  7. 读《财务就是IT 企业财务信息系统》
  8. 【课程·研】高性能计算机网络 | 学堂在线习题解答:期末考试
  9. DevExpress ChartControl 绘制圆滑曲线
  10. 使用mingw编译log4cpp--问题整理