Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson2-3-1_DIY1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0ad3a5d7
authored
Apr 24, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
23dfff73
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
diy1.py
diy1.py
0 → 100644
View file @
0ad3a5d7
# 石头剪刀布
choices
=
[
'石头'
,
'布'
,
'剪刀'
]
print
(
'Hi,训练师!我是编程猫!很高兴遇见你!现在我们来玩石头剪刀布的游戏吧!'
)
print
(
'石头剪刀布!'
)
player
=
input
(
'你要出石头呢,还是剪刀呢,还是布?(如输入“退出”,可退出游戏)'
)
# 直到退出游戏之前,下面的循环都会继续
while
(
player
!=
'退出'
):
# 验证玩家和电脑各自的选择
computer
=
random
.
choice
(
choices
)
print
(((((
'你出了'
+
player
)
+
',电脑出了'
)
+
computer
)
+
'...'
))
if
(
player
==
computer
):
print
(
'平局!'
)
elif
(
player
==
'石头'
):
if
(
computer
==
'剪刀'
):
print
(
'你赢了!'
)
else
:
print
(
'电脑赢了!'
)
elif
(
player
==
'布'
):
if
(
computer
==
'石头'
):
print
(
'你赢了'
)
else
:
print
(
'电脑赢了!'
)
elif
(
player
==
'剪刀'
):
if
(
computer
==
'布'
):
print
(
'你赢了'
)
else
:
print
(
'电脑赢了!'
)
else
:
print
(
'出错了哦!只能出“石头”“剪刀”或“布”!'
)
# 立即再来一轮,直到退出游戏
print
(
'石头剪刀布!'
)
player
=
input
(
'你要出石头呢,还是剪刀呢,还是布?(如输入“退出”,可退出游戏)'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment