zoukankan      html  css  js  c++  java
  • ex31--作出决定

     本练习以一个冒险游戏的形式,在if语句内部再放入一个If语句,用来创建嵌套的决定。

    常见问题回答:如何判断一个值是否在某个值域中?经典语法是使用 if 1<x<10,或者也可以用if x in range (1,10)

    以下是练习源代码。讲真最后一个if语句里的单词好几个不认识。。。。

     1 #-*- coding: UTF-8 -*-
     2 print "You enter a dark room with two doors,Do you go through door #1 or #2?"
     3 
     4 door = raw_input(">")
     5 
     6 if door == "1":
     7     print "There is a gaint bear here eating a cheese cake.What do you do?"
     8     print "1.Take the cake."
     9     print "2.Scream at the bear."
    10     
    11     bear = raw_input(">")
    12     
    13     if bear == "1":
    14         print "The bear eats your face off.Good job!"
    15     elif bear == "2":
    16         print "The bear eats your legs off. Good job!"
    17     else:
    18         print "Well,doing %s is propably better. Bear runs away." %bear
    19         
    20 elif door == "2":
    21     print "You stare into the endless abyss at Cthulhu's retina."
    22     print "1.Blueberries."
    23     print "2.Yellow jacket clothespins."
    24     print "3.Understanding revolvers yelling melodies."
    25     
    26     insanity = raw_input(">")
    27     if insanity == "1" or insanity =="2":
    28         print "Your body survies powered by a mind of jello.Good job."
    29     elif insanity == "3":
    30         print "The insanity rots your eyes into a pool of muck.Good job!"
    31         
    32     else:
    33         print "You stumble around and fall on a knife and die."
    34     
  • 相关阅读:
    游标+递归 查询 客户 子客户 查询财务信用
    导入EXCEL
    ftp读取txt数据并插入数据库
    查询通话时间报表
    4.10上午
    4.7下午
    4.6下午
    4.6上午
    4.5上午
    4.1下午
  • 原文地址:https://www.cnblogs.com/dingtou00/p/7784775.html
Copyright © 2011-2022 走看看