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
ef8997a2
authored
Jul 23, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
8b729148
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
diy.py
diy.py
View file @
ef8997a2
import
random
import
random
#调用随机数
wanjia
=
input
(
"请出拳"
)
play
=
input
(
"请出拳:"
)
#人机交互
list
=
[
"剪刀"
,
"石头"
,
"布"
]
list
=
[
"剪刀"
,
"布"
,
"石头"
]
#出拳集合
computer
=
random
.
choice
(
list
)
computer
=
random
.
choice
(
list
)
#从集合中随机出拳
print
(
"玩家出"
+
wanjia
+
"电脑出"
+
computer
)
print
(
"玩家出"
+
play
+
"电脑出"
+
computer
)
#输出出拳结果
if
play
in
list
:
if
play
==
computer
:
#判断是否平局
print
(
"平局哦"
)
elif
(
play
==
"剪刀"
and
computer
==
"布"
)
or
(
play
==
"石头"
and
computer
==
"剪刀"
)
or
(
play
==
"布"
and
computer
==
"石头"
):
#判断是否获胜
print
(
"赢啦赢啦"
)
else
:
print
(
"你输啦"
)
else
:
print
(
"输入错误啦"
)
\ No newline at end of file
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