Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson2-2_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
49e6110b
authored
Mar 26, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
25abb509
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
3 deletions
diy1.py
diy1.py
View file @
49e6110b
player
=
input
(
"请出拳:石头/剪刀/布"
)
# 玩家出拳
print
(
"玩家出拳:"
+
player
)
\ No newline at end of file
# 命名变量,记录出拳的变量
ChuQuan
=
input
(
"请出拳:"
)
print
(
ChuQuan
)
# 导入随机库
import
random
# 设置列表
zhuzhuxia
=
[
"石头"
,
"剪刀"
,
"布"
]
# 随机取出列表里面的值
DianNaoChuQuan
=
random
.
choice
(
zhuzhuxia
)
#随机选择列表中的值
print
(
DianNaoChuQuan
)
# 判断输赢.if条件判断,
# if+条件:只有一个结果的判断的书写格式
# if...elif...elif...else:有多个结果的判断的书写格式
if
ChuQuan
==
DianNaoChuQuan
:
print
(
"平局了"
)
elif
ChuQuan
==
"石头"
and
DianNaoChuQuan
==
"剪刀"
:
print
(
"你赢了"
)
elif
ChuQuan
==
"剪刀"
and
DianNaoChuQuan
==
"布"
:
print
(
"你赢了"
)
elif
ChuQuan
==
"布"
and
DianNaoChuQuan
==
"石头"
:
print
(
"你赢了"
)
else
:
print
(
"你输了"
)
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