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
08ac2d80
authored
Apr 10, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
379c66b4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
19 deletions
diy1.py
diy1.py
View file @
08ac2d80
import
random
import
random
d1
=
0
d2
=
0
list
=
[
'石头'
,
'剪刀'
,
'布'
]
list
=
[
'石头'
,
'剪刀'
,
'布'
]
j
=
random
.
choice
(
list
)
n
=
input
(
'请输入轮数:'
)
w
=
input
(
'玩家出拳(石头/剪刀/布):'
)
n
=
int
(
n
)
print
(
'玩家出'
+
w
)
for
i
in
range
(
n
):
print
(
'计算机出'
+
j
)
j
=
random
.
choice
(
list
)
if
w
==
'石头'
and
j
==
'剪刀'
:
w
=
input
(
'玩家出拳(石头/剪刀/布):'
)
print
(
'玩家赢'
)
if
w
!=
'石头'
and
w
!=
'剪刀'
and
w
!=
'布'
:
elif
w
==
'石头'
and
j
==
'布'
:
print
(
'输入错误'
)
print
(
'计算机赢'
)
continue
elif
w
==
'剪刀'
and
j
==
'石头'
:
print
(
'玩家出'
+
w
)
print
(
'计算机赢'
)
print
(
'计算机出'
+
j
)
elif
w
==
'剪刀'
and
j
==
'布'
:
if
w
==
'石头'
and
j
==
'剪刀'
:
print
(
'玩家赢'
)
print
(
'玩家赢'
)
elif
w
==
'布'
and
j
==
'石头'
:
d1
+=
1
print
(
'玩家赢'
)
elif
w
==
'石头'
and
j
==
'布'
:
elif
w
==
'布'
and
j
==
'剪刀'
:
print
(
'计算机赢'
)
print
(
'计算机赢'
)
d2
+=
1
if
w
==
j
:
elif
w
==
'剪刀'
and
j
==
'石头'
:
print
(
'平局'
)
print
(
'计算机赢'
)
\ No newline at end of file
d2
+=
1
elif
w
==
'剪刀'
and
j
==
'布'
:
print
(
'玩家赢'
)
d1
+=
1
elif
w
==
'布'
and
j
==
'石头'
:
print
(
'玩家赢'
)
d1
+=
1
elif
w
==
'布'
and
j
==
'剪刀'
:
print
(
'计算机赢'
)
d2
+=
1
if
w
==
j
:
print
(
'平局'
)
if
d1
<
d2
:
print
(
'很遗憾,计算机赢了'
)
elif
d1
==
d2
:
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