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
3340478d
authored
Feb 04, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
a0cbfb52
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
diy1.py
diy2.py
diy1.py
View file @
3340478d
# 玩家出拳
# 玩家出拳
\ No newline at end of file
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
(
"很遗憾,你输了!"
)
else
:
print
(
"输入错误"
)
\ No newline at end of file
diy2.py
0 → 100644
View file @
3340478d
week
=
{
1
:
"星期一"
,
2
:
"星期二"
,
3
:
"星期三"
,
4
:
"星期四"
,
5
:
"星期五"
,
6
:
"星期六"
,
7
:
"星期日"
}
day
=
int
(
input
(
"请输入今天多少号:"
))
day
=
day
%
7
if
day
==
1
:
print
(
week
[
1
])
elif
day
==
2
:
print
(
week
[
2
])
elif
day
==
3
:
print
(
week
[
3
])
elif
day
==
4
:
print
(
week
[
4
])
elif
day
==
5
:
print
(
week
[
5
])
elif
day
==
6
:
print
(
week
[
6
])
else
:
print
(
week
[
7
])
\ 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