Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson2-5_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
89d16e3b
authored
Aug 06, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
e1f2c52d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
14 deletions
diy1.py
diy1.py
View file @
89d16e3b
player
=
input
(
"请出拳:(石头/剪刀/布)"
)
# 玩家出拳
print
(
"玩家出拳:"
+
player
)
import
random
list
=
[
"石头"
,
"剪刀"
,
"布"
]
computer
=
random
.
choice
(
list
)
print
(
"电脑出拳"
+
computer
)
if
player
in
list
:
if
player
==
computer
:
print
(
"平局"
)
elif
(
player
==
"石头"
and
computer
==
"剪刀"
)
or
(
player
==
"剪刀"
and
computer
==
"布"
)
or
(
player
==
"布"
and
computer
==
"石头"
):
print
(
"恭喜,你赢了"
)
else
:
print
(
"很遗憾,你输了"
)
good
=
0
a
=
input
(
"一还是二?(请打汉字~)"
)
print
(
"本次石头剪刀布比赛采用回合制,共五次,三局两胜制"
)
print
(
"————————————————————————————————————————————————"
)
for
i
in
range
(
5
):
if
a
==
"一"
:
player
=
input
(
"请出拳:(石头/剪刀/布)"
)
# 玩家出拳
print
(
"玩家出拳:"
+
player
)
import
random
list
=
[
"石头"
,
"剪刀"
,
"布"
]
computer
=
random
.
choice
(
list
)
print
(
"电脑出拳:"
+
computer
)
if
player
in
list
:
if
player
==
computer
:
print
(
"本次结果:平局"
)
elif
(
player
==
"石头"
and
computer
==
"剪刀"
)
or
(
player
==
"剪刀"
and
computer
==
"布"
)
or
(
player
==
"布"
and
computer
==
"石头"
):
print
(
"本次结果:恭喜,你赢了"
)
good
=
good
+
1
else
:
print
(
"本次结果:很遗憾,你输了"
)
else
:
print
(
"输入错误"
)
elif
a
==
"二"
:
player
=
input
(
"请出拳:(石头/剪刀/布)"
)
# 玩家出拳
print
(
"玩家出拳:"
+
player
)
if
player
==
"石头"
:
computer
=
"剪刀"
if
player
==
"剪刀"
:
computer
=
"布"
if
player
==
"布"
:
computer
=
"石头"
print
(
"电脑出拳:"
+
computer
)
if
(
player
==
"剪刀"
)
or
(
player
==
"石头"
)
or
(
player
==
"布"
):
if
player
==
computer
:
print
(
"本次结果:平局"
)
elif
(
player
==
"石头"
and
computer
==
"剪刀"
)
or
(
player
==
"剪刀"
and
computer
==
"布"
)
or
(
player
==
"布"
and
computer
==
"石头"
):
print
(
"本次结果:恭喜,你赢了"
)
good
=
good
+
1
else
:
print
(
"本次结果:很遗憾,你输了"
)
else
:
print
(
"输入错误"
)
else
:
print
(
"请重新选择"
)
if
good
>
2
:
print
(
"比赛结果:恭喜你,取得了比赛的胜利"
)
elif
good
<
3
:
print
(
"比赛结果:很遗憾,你没有获得胜利,请再接再厉"
)
else
:
print
(
"输入错误"
)
\ No newline at end of file
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