猫史档案馆


【Python作品分享】幽灵游戏【作品秀】

用户:AOR.一念.仙破叶城AOR.一念.仙破叶城查看:0 回复:0 评论:0 创建时间:2022-05-26T15:40:31


【作品展示】

center_image

 

【作品介绍】

幽灵游戏,选择3扇门的其中一个,其中有一扇门有幽灵,碰到了就输了哟

 

【作品源代码】

import random
from random import randint


# Ghost Game

print('Ghost Game')
feeling_brave = True
score = 0
while feeling_brave:
    ghost_door = random.randint(1, 3)
    print('Three doors ahead...')
    print('A ghost behind one.')
    print('Which door do you open?')
    door = input('1,2 or 3')
    door_num = int(door)
    if (door_num == ghost_door):
        print('GHOST')
        feeling_brave = False
    else:
        print('No ghost!')
        print('You enter the next room.')
        score = (score + 1)
print('Run away!')
print('Game over! You scored', score)

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页