Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson2-1-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
8742ffe5
authored
Aug 28, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
55e28e3a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
12 deletions
1.py
2.py
star.py
1.py
0 → 100644
View file @
8742ffe5
#导入random模块
#玩家出拳
player
=
input
(
'玩家出拳:'
)
print
(
"player:"
+
player
)
# input()输入的内容都是字符串
#创建列表 用来存放石头剪刀布 alist
#计算机出拳:通过random.choice()
#输出一下计算机出拳
#如果玩家等于计算机 就平局
#如果玩家出石头 and 计算机出剪刀 or 玩家出布and计算机出石头 or 玩家出剪刀and计算机出布 玩家获胜
#else: 计算机获胜
\ No newline at end of file
2.py
0 → 100644
View file @
8742ffe5
条件判断语句
单分支条件判断语句
if
条件
:
条件成立时执行的语句
双分支条件判断语句
if
条件
:
条件成立时执行的语句
else
:
条件不成立时执行的语句
多分支条件判断语句
elif
可以出现多次
当有一个分支成立时就不会执行其他分支
if
条件
:
条件成立时执行的语句
elif
条件
1
:
条件
1
成立时执行的语句
elif
条件
2
:
条件
2
成立时执行的语句
elif
条件
3
:
条件
3
成立时执行的语句
else
:
条件不成立时执行的语句
\ No newline at end of file
star.py
View file @
8742ffe5
# 上节课你是这样绘制的五角星👇:
import
random
# 这节课你可以利用新学的知识自定义五角星的颜色么?
while
True
:
import
turtle
a
=
input
(
"石头/剪刀/布"
)
ink
=
input
(
"什么色?"
)
#绘制五角星#
if
a
!=
"石头"
and
"剪刀"
and
"布"
:
pen
=
turtle
.
Pen
()
print
(
"plz retype"
)
pen
.
fillcolor
(
ink
)
break
pen
.
begin_fill
()
else
:
for
i
in
range
(
5
):
#重复执行5次
if
a
==
"石头"
:
pen
.
forward
(
200
)
#向前移动200步
b
=
1
pen
.
right
(
144
)
#向右移动144度,注意这里的参数一定不能变
if
a
==
"剪刀"
:
pen
.
end_fill
()
#结束填充红色
b
=
2
turtle
.
done
()
if
a
==
"布"
:
b
=
3
print
(
"玩家出"
+
a
)
c
=
random
.
randint
(
1
,
3
)
if
c
==
1
:
print
(
"人机出石头"
)
if
c
==
2
:
print
(
"人机出剪刀"
)
if
c
==
3
:
print
(
"人机出布"
)
if
c
==
b
:
print
(
"平局"
)
if
b
==
1
and
c
==
2
:
print
(
"玩家赢"
)
if
b
==
2
and
c
==
3
:
print
(
"玩家赢"
)
if
b
==
3
and
c
==
1
:
print
(
"玩家赢"
)
if
c
==
1
and
b
==
2
:
print
(
"人机赢"
)
if
c
==
2
and
b
==
3
:
print
(
"人机赢"
)
if
c
==
3
and
b
==
1
:
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