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
1d5af79a
authored
Jul 19, 2020
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
b5c6bbbe
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
0 deletions
diy1.py
saj.py
zg.py
diy1.py
0 → 100644
View file @
1d5af79a
import
random
i
=
0
while
i
<
10
:
playerStr
=
input
(
"请输入[0剪刀 1石头 2布]"
)
player
=
int
(
playerStr
)
mac
=
random
.
randint
(
0
,
2
)
if
(
player
==
0
and
mac
==
2
)
or
(
player
==
1
and
mac
==
0
)
or
(
player
==
2
and
mac
==
1
):
print
(
"你赢了"
)
elif
player
==
mac
:
print
(
"平局,要不要再来一句"
)
else
:
print
(
"你输了"
)
i
=
1
saj.py
0 → 100644
View file @
1d5af79a
import
random
tj
=
{
'胜'
:
0
,
'负'
:
0
,
'平'
:
0
,
'次数'
:
0
}
quanList
=
[
'剪刀'
,
'石头'
,
'布'
]
def
myGame
():
while
True
:
myQuan
=
input
(
"请出拳:
\n
"
)
computerQuan
=
random
.
choice
(
quanList
)
if
myQuan
==
'exit'
:
print
(
'下次再来玩!'
)
print
(
'胜:
%
s 负:
%
s 平:
%
s 次数:
%
s'
%
(
tj
[
'胜'
],
tj
[
'负'
],
tj
[
'平'
],
tj
[
'次数'
]))
tj
[
'胜'
]
=
0
tj
[
'负'
]
=
0
tj
[
'平'
]
=
0
tj
[
'次数'
]
=
0
break
elif
myQuan
not
in
quanList
:
print
(
'错误的值'
)
continue
elif
myQuan
==
random
.
choice
(
quanList
):
print
(
'打平'
)
tj
[
'平'
]
+=
1
tj
[
'次数'
]
+=
1
continue
elif
(
myQuan
==
quanList
[
0
]
and
computerQuan
==
quanList
[
2
])
or
(
myQuan
==
quanList
[
1
]
and
computerQuan
==
quanList
[
0
])
or
(
myQuan
==
quanList
[
2
]
and
computerQuan
==
quanList
[
2
]):
print
(
'赢了!'
)
tj
[
'胜'
]
+=
1
tj
[
'次数'
]
+=
1
continue
else
:
print
(
'你输了!'
)
tj
[
'负'
]
+=
1
tj
[
'次数'
]
+=
1
continue
myGame
()
\ No newline at end of file
zg.py
0 → 100644
View file @
1d5af79a
a
=
input
(
"输入"
)
a
=
int
(
a
)
if
a
==
10
:
print
(
"等于"
)
elif
:
if
a
<
10
:
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