LearnPython3theHardWay__Excercise 31 Making Decisions
建议ex27-31连起来学习
迄今为止,我们学会输出字符串和函数,这些基础足够让我们的代码从头开始运行,到尾部结束。现在我们有了if,else和elif,像上一节练习,我们可以开始让脚本做决策了。
注意,使用了 if 的嵌套,另外,脚本内容有点儿童不宜。。。
print("""You enter a dark room with two doors.
Do you go though door #1 or door #2?""")door = input('>')if door == "1":print("There's a giant bear here eating a cheese cake.")print("What do you do?")print("1. Take the cake.")print("2. Scream at the bear.")bear = 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(f"Well, doing {bear} is probably better.")print("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 = input('>')if insanity == '1' or insanity == '2':print("Your body survives powered by a mind of jello.")print("Good job!")else:print("The insanity rots your eyes into a pool of muck.")print("Good job!")else:print("You stumble around and fall on a knife and die. Good job!")
What you should see
You enter a dark room with two doors.
Do you go though door #1 or door #2?
>1
There's a giant bear here eating a cheese cake.
What do you do?
1. Take the cake.
2. Scream at the bear.
>2
The bear eats your legs off. Good job!
Study Drills
- 改编一下脚本的内容,给出更多选择。
- 写一个完整的新游戏。
LearnPython3theHardWay__Excercise 31 Making Decisions相关推荐
- 程序员学炒股(7) 股指期货收盘价对第二天开盘价有影响吗?
很多微博和文章都说,股指期货的收盘价对第二天开盘价影响很大,因为股指多交易15分钟,因此对股市的第二天开盘价影响非常大,网上有一个文章是这样说的: "股指期货开盘早于股市15分钟,收盘又晚1 ...
- The right to contest automated decisions under the General Data Protection Regulation: Beyond the so
Regulation & Governa nee Regulation & Governance (2021) doi:10.1111/rego.12391 The right to ...
- What is T abby? Interpretable Model Decisions by Learning Attribute-based Classification Criteria翻译*
What is T abby? Interpretable Model Decisions by Learning Attribute-based Classification Criteria翻译 ...
- 软件工程 实践者的研究方法 第31章答案
Problem: Based on information contained in this chapter and your own experience, develop "10 co ...
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(31)-MVC使用RDL报表
原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(31)-MVC使用RDL报表 这次我们来演示MVC3怎么显示RDL报表,坑爹的微软把MVC升级到5都木有良 ...
- 【组队学习】【31期】组队学习内容详情
第31期 Datawhale 组队学习活动马上就要开始啦! 本次组队学习的内容为: IOS开发 基于Python的办公自动化 吃瓜教程--西瓜书+南瓜书 LeetCode 刷题 李宏毅机器学习(含深度 ...
- 31个好用的 Python 字符串方法,建议收藏!
作者 | 小F 来源 | 法纳斯特 字符串是Python中基本的数据类型,几乎在每个Python程序中都会使用到它. 今天,就带大家学习一下31个最重要的内置字符串方法. 希望大家能从中找到对自己有帮 ...
- 31页PPT概述:图神经网络表达能力有多强?
整理 | 一一 出品 | AI科技大本营 近年来,图神经网络的研究成为深度学习领域的热点. 图是一种数据结构,它对一组对象(节点)及其关系(边)进行建模,由于图结构的强大表现力,用机器学习方法分析图的 ...
- 第31届NIPS正式开幕,3240篇提交论文创历史新高,公布3篇最佳论文
美国时间12月4日,第31届NIPS在美国加州长滩的会展中心正式开幕! 之所以NIPS广受关注,是因为它在人工智能和机器学习领域具有重要地位,来自全世界的计算机科学家及资深业内人士将在接下来的五天,共 ...
最新文章
- Udacity机器人软件工程师课程笔记(二十二) - 物体识别 - 色彩直方图,支持向量机SVM
- Cell:绝对异养型生物改造成完全自养型生物
- LeetCode 42. Trapping Rain Water--算法题--c++解法
- DuiC 统一配置管理 2
- FM之NUMERIC_CHECK
- Linux内存page,Linux虚拟内存管理 - Page Table的作用
- HTML5新属性 Canves的整体学习
- 检查eth是否到账_花费32个ETH参与以太坊2.0是件很难的事吗?
- day15【前台】项目发布
- extjs 网站首页table布局,秀一下
- form表单target实现当前页表单提交而不进行跳转刷新
- DIV下的DIV居中
- C++11之final详解
- 汽车诊断协议 - CAN BUS协议
- hook 微信公众号html,Xposed实时获取微信公众号推送
- TSL2591STM32固件库开发
- golang下文件锁的使用
- 教学中常用的计算机软件及作用,信息技术教学中常用的教学方法有哪些
- OLED屏幕笔记本 | 看久了眼睛不舒服 | 调整
- 关联规则之购物篮分析