Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson3-1-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
9d8a0f5a
authored
Jul 20, 2020
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
c2f1308f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
diy1.py
diy1.py
View file @
9d8a0f5a
# 利用write()帮助悟空给诺依回信吧~
\ No newline at end of file
# 导入模块
import
random
# 输入玩家信息
player
=
input
(
"请输入(石头/剪刀/布):"
)
# 输出玩家信息
print
(
"玩家出拳:"
+
player
)
#输出计算机随机数
list1
=
[
"石头"
,
"剪刀"
,
"布"
]
computer
=
random
.
choice
(
list1
)
print
(
"计算机出拳:"
,
computer
)
if
player
in
list1
:
#逻辑判断,石头剪刀布的输赢
if
player
==
computer
:
print
(
"平局了!"
)
elif
player
==
"石头"
and
computer
==
"剪刀"
or
player
==
"剪刀"
and
computer
==
"布"
or
player
==
"布"
and
computer
==
"石头"
:
print
(
"我赢了,好开心!"
)
else
:
print
(
"我输了,不开心!"
)
else
:
print
(
"请不要乱输入,否则我就打110!"
)
\ 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