Exercise 31: Making Decisions

print "You enter a dark room with two doors. Do you go through door #1 or door #2?"
door = raw_input("> ")
if door == "1":
  print "There‘s 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." % bear
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 revolve  rs 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. Good job!"
时间: 2024-11-05 06:12:14

Exercise 31: Making Decisions的相关文章

Exercise 31 - if

print("You enter a dark room with two doors. Do you want to enter door #1 or door #2?") door = input("> ") if door == "1": print("There's a gaint bear here eating a cheese cake. What do you do?") print("1. T

Python Index

Table Of ContentsThe Hard Way Is EasierExercise 0: The SetupExercise 1: A Good First ProgramExercise 2: Comments And Pound CharactersExercise 3: Numbers And MathExercise 4: Variables And NamesExercise 5: More Variables And PrintingExercise 6: Strings

2017/8/4 SCJP学习

2 Object Orientation . . . . . . . . . . . . . . . . . . . . . . . . . 85 Encapsulation (Exam Objective 5.1) . . . . . . . . . . . . . 86 Inheritance, Is-A, Has-A (Exam Objective 5.5) . . . . . . . . . 90 IS-A . . . . . . . . . . . . . . . . . . . .

程序员学炒股(7) 股指期货收盘价对第二天开盘价有影响吗?

很多微博和文章都说,股指期货的收盘价对第二天开盘价影响很大,因为股指多交易15分钟,因此对股市的第二天开盘价影响非常大,网上有一个文章是这样说的: “股指期货开盘早于股市15分钟,收盘又晚15分钟,国泰君安研究员曾统计,股指期货晚收盘15分钟的涨跌对于次日期指走势的预测准确率达到了70%.” 看看这个文章的作者是江恩艾略特道氏,虽然不知道是啥,但是看着还是很唬人的,再看看这篇文章的访问次数695567次,可见还是有影响力的. 如果这篇文章说的是真的话,能够预测到第二天开盘的大盘也是很不错滴,我们

Exercise 3.3 Calculate a discounted price

Exercise 3-3. Write a program that will calculate the price for a quantity entered from the keyboard, given that the unit price is $5 and there is a discount of 10 percent for quantities over 30 and a 15 percent discount for quantities over 50. 1 //

[Usaco2010 Dec]Exercise 奶牛健美操

[Usaco2010 Dec]Exercise 奶牛健美操 题目 Farmer John为了保持奶牛们的健康,让可怜的奶牛们不停在牧场之间 的小路上奔跑.这些奶牛的路径集合可以被表示成一个点集和一些连接 两个顶点的双向路,使得每对点之间恰好有一条简单路径.简单的说来, 这些点的布局就是一棵树,且每条边等长,都为1. 对于给定的一个奶牛路径集合,精明的奶牛们会计算出任意点对路径的最大值, 我们称之为这个路径集合的直径.如果直径太大,奶牛们就会拒绝锻炼. Farmer John把每个点标记为1..V

<<C++ Primer>> 第四版Exercise Section 8.4.1 练习题

For exercise 8.6 1 // ConsoleApplication10.cpp : 定义控制台应用程序的入口点. 2 // 3 4 #include "stdafx.h" 5 #include <iostream> 6 #include <fstream> 7 #include <sstream> 8 9 using namespace std; 10 11 12 void print(istream &in) 13 { 14

*Exercise 5.1 Summing reciprocals of five values

Exercise 5-1. Write a program that will read five values of type double from the keyboardand store them in an array. Calculate the reciprocal of each value (the reciprocal ofvalue x is 1.0/x) and store it in a separate array. Output the values of the

Exercise 3.2 Display a date

无法让我不汗颜: Exercise 3-2. Write a program that prompts the user to enter the date as three integer values for the month, the day in the month, and the year. the program should then output the date in the form 31st December 2003 when the user enters 12 3