标签:color 第一个 head span auth hose 硬币 author display
1 __Author__ = "Cheney" 2 3 4 import random 5 import time 6 7 def displayIntro(): 8 print(‘你现在所处的大陆充满了恐龙‘) 9 time.sleep(2) 10 print(‘在你的前面,你会看到两个洞穴‘) 11 time.sleep(3) 12 print(‘在第一个洞穴里面这个恐龙是好的,它愿意和你分享它的财富‘) 13 print(‘另外一个恐龙是贪婪的,它会把你吃掉‘) 14 print() 15 16 def chooseCave(): 17 cave = ‘‘ 18 while cave != ‘1‘ and cave != ‘2‘: 19 print(‘你会选择那个???(1 or 2)‘) 20 cave = input() 21 22 return cave #return跳出def模块 23 24 def checkCave(chosenCave): 25 print(‘你接近了一个洞穴...‘) 26 time.sleep(3) 27 print(‘这里非常的黑...‘) 28 time.sleep(2) 29 print(‘一个恐龙接近了你,张开了它的大嘴....‘) 30 print() 31 time.sleep(2) 32 33 friendlyCave = random.randint(1,2) 34 35 if chosenCave == str(friendlyCave): 36 print(‘把它的财宝都给了你‘) 37 else: 38 print(‘一口把你吞下去了‘) 39 40 playAgain = ‘yes‘ 41 while playAgain == ‘yes‘ or playAgain == ‘y‘: 42 43 displayIntro() 44 45 caveNumber = chooseCave() 46 47 checkCave(caveNumber) 48 49 print(‘你还想再玩一次吗?(yes or on)‘) 50 playAgain = input()
1 import random 2 print(‘我抛1000次硬币,猜猜看有多少次正面朝上.按回车开始~‘) 3 input() 4 flips = 0 5 heads = 0 6 while flips < 1000: 7 if random.randint(0,1) == 1: 8 heads = heads + 1 9 flips = flips + 1 10 if flips == 10: 11 print(‘10次里面,有‘ + str(heads) + ‘次硬币面朝上‘) 12 if flips == 900: 13 print(‘900次里面,有‘ + str(heads) + ‘次硬币面朝上‘) 14 if flips == 100: 15 print(‘100次里面,有‘ + str(heads) + ‘次硬币面朝上‘) 16 if flips == 500: 17 print(‘做了一半了,有‘ + str(heads) + ‘次硬币面朝上‘) 18 19 print() 20 print(‘1000次结束了,正面朝上的有‘ + str(heads) + ‘次‘) 21 print(‘不满意可以再来一次‘)
标签:color 第一个 head span auth hose 硬币 author display
原文地址:http://www.cnblogs.com/chenwz/p/7802850.html