【python】Word Jumble
2015-07-30 16:40
686 查看
By dolphin,20150730
Title :
改进Word Jumble,给各个单词加上一个提示。让玩家在遇到困难时能够看到提示。添加一个记分系统,对那些不用提示就把问题解决掉的玩家进行奖励。
Code:
Title :
改进Word Jumble,给各个单词加上一个提示。让玩家在遇到困难时能够看到提示。添加一个记分系统,对那些不用提示就把问题解决掉的玩家进行奖励。
Code:
# Word Jumble # # Computer random chosse a word, and disturb it # The player must guess the word. import random WORDS = ("python", "jumble", "easy", "difficult", "elephant", "iphone", "Dolphin") word = random.choice(WORDS) correct = word score = 0 tips = 0 # Creat a disturb word jumble = "" while word: position = random.randrange(len(word)) jumble += word[position] word = word[:position] + word[(position + 1 ):] # Play game print( """ Welcome to Word Jumble ! Unscramble the letters to make a word. (Press the enter key at the prompt to quit .) """) print("\nThe jumble is : ",jumble) print("\n Press h to get the tips.") # Get answer guess = input("\n Your guess:") # Get Tips while guess != correct and guess != "": if guess == 'h': if correct == 'python': print("A computer langue !") elif correct == 'jumble': print("A word puzzle with a clue.") elif correct == 'easy': print("Opposite word is difficult !") elif correct == 'difficult': print("Opposite word is easy !") elif correct == 'elephant': print("A very large animal with a long, flexible nose.") elif correct == 'iphone': print("A mobile phone.") else : print("It is me ") guess = input("Guess again: ") tips = 1 else: print("Sorry , that is not it.") guess = input("Guess again: ") # Get Score if tips == 1 : score = 50; if tips == 0 : score = 100; # result if guess == correct: print("\nYeah! That's it ! You guessed it !\n") print("Your score is ",score) print("\nThanks for playing ! ") input("\n\nPress the enter key to exit !")
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例
- Python 七步捉虫法
- Python实现的基于ADB的Android远程工具