Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson8-5
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
491bff00
authored
Sep 24, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
6a980f48
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
3 deletions
demo.py
diy.py
demo.py
0 → 100644
View file @
491bff00
#导入海龟库
import
turtle
as
t
#导入随机数模块
import
random
#创建画笔
pen
=
t
.
Turtle
()
#设置画笔颜色
pen
.
color
(
"sienna"
)
#设置画笔的速度
pen
.
speed
(
0
)
#设置画布的大小
w
=
t
.
Screen
()
w
.
bgcolor
(
"wheat"
)
#小麦色
#移动到起点
pen
.
left
(
90
)
pen
.
up
()
pen
.
backward
(
150
)
pen
.
down
()
#画树枝 创建tree函数
def
tree
(
n
):
#判断n是否大于0
if
n
>=
0
:
if
n
<=
12
:
color_list
=
[
"snow"
,
"lightcoral"
]
color
=
random
.
choice
(
color_list
)
pen
.
color
(
color
)
pen
.
pensize
(
n
/
3
)
else
:
pen
.
color
(
"sienna"
)
#赭色
pen
.
pensize
(
n
/
10
)
pen
.
forward
(
n
)
angle
=
random
.
random
()
pen
.
right
(
30
*
angle
)
length
=
1.5
*
random
.
random
()
#调用tree函数
tree
(
n
-
10
*
length
)
pen
.
left
(
60
*
angle
)
tree
(
n
-
10
*
length
)
pen
.
right
(
30
*
angle
)
pen
.
up
()
pen
.
backward
(
n
)
pen
.
down
()
tree
(
60
)
t
.
done
()
\ No newline at end of file
diy.py
View file @
491bff00
...
...
@@ -3,12 +3,13 @@
cost
=
{
'苹果'
:
5.2
,
'山竹'
:
12.9
,
'香蕉'
:
2.4
,
'荔枝'
:
15
,
'葡萄'
:
9.3
,
'桂圆'
:
8
,
'蓝莓'
:
10
,
'李子'
:
8
}
k
=
input
(
'请输入水果名称:'
)
v
=
input
(
'请输入水果价钱:'
)
# ?补充条件判断
:
if
# ?
:
# ?更新价钱
if
k
in
cost
:
if
float
(
v
)
<
cost
[
k
]
:
cost
[
k
]
=
float
(
v
)
print
(
k
+
'降价了,现价'
+
v
+
'元'
)
else
:
print
(
k
+
'涨价了,我们不买'
)
else
:
cost
[
k
]
=
float
(
v
)
print
(
k
+
'的价钱'
+
v
+
'元已上传~'
)
#魏诗航
\ 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