【Python】基础-猜单词游戏
本文最后更新于 1524 天前,其中的信息可能已经有所发展或是发生改变。

[success]一个简单的猜单词,用到random随机函数。作为学习记录一下。[/success]

[sourcecode language=”python” title=”demo.py”]
import random
WORDS = ("python", "Jumble", "easy", "difficult", "answer", "continue", "phone", "posittion", "position", "game")
print(
"""
欢迎参加猜单词游戏
把字母组成一个正确的单词
"""
)
iscontinue = "y"
while iscontinue=="y" or iscontinue=="Y":
word = random.choice(WORDS)
correct = word
jumble = ""
while word:
position = random.randrange(len(word))
jumble += word[position]
word = word[:position] + word[(position+1):]
print("乱序后的单词:"+jumble)
guess = input("\n请你猜:")
while guess != correct and guess != "":
print("对不起不正确。")
guess = input("继续猜:")
if guess == correct:
print("猜对了!\n")
iscontinue = input("是否继续(Y/N):")
[/sourcecode]

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇