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
923c1737
authored
Aug 22, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
e563dd6e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
16 deletions
Untitled-1.py.py
diy1.py
Untitled-1.py.py
0 → 100644
View file @
923c1737
i
=
0
while
i
<
10
:
print
(
"*"
*
i
)
i
=
i
+
1
i
=
10
while
i
>
0
:
print
(
"*"
*
i
)
i
=
i
-
1
diy1.py
View file @
923c1737
# 玩家出拳
player
=
input
(
"请出拳(石头、剪刀、布)"
)
print
(
"玩家出拳为"
+
player
)
import
turtle
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
(
"玩家输了"
)
num
=
input
(
"请输入边数"
)
print
(
type
(
num
))
color
=
input
(
"请输入颜色"
)
color_list
=
[
"red"
,
"green"
,
"blue"
,
"black"
,
"pink"
]
if
num
==
"随机"
:
num
=
random
.
randint
(
2
,
10
)
else
:
print
(
"输入错误"
)
\ No newline at end of file
num
=
int
(
num
)
if
color
==
"随机"
:
color
=
random
.
choice
(
color_list
)
if
not
num
>
2
and
num
<
10
:
print
(
"边数错误"
)
if
not
color
in
color_list
:
print
(
"颜色不对"
)
pen
=
turtle
.
Pen
()
pen
.
fillcolor
(
color
)
pen
.
begin_fill
()
angle
=
180
*
(
num
-
2
)
/
num
for
i
in
range
(
num
):
pen
.
forward
(
random
.
randint
(
1
,
100
))
pen
.
left
(
180
-
angle
)
pen
.
end_fill
()
turtle
.
done
()
pen
.
hideturtle
()
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