Commit 491bff00 by BellCodeEditor

auto save

parent 6a980f48
Showing with 50 additions and 3 deletions
#导入海龟库
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
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
cost= {'苹果':5.2,'山竹':12.9,'香蕉':2.4,'荔枝':15,'葡萄':9.3,'桂圆':8,'蓝莓':10,'李子':8} cost= {'苹果':5.2,'山竹':12.9,'香蕉':2.4,'荔枝':15,'葡萄':9.3,'桂圆':8,'蓝莓':10,'李子':8}
k=input('请输入水果名称:') k=input('请输入水果名称:')
v=input('请输入水果价钱:') v=input('请输入水果价钱:')
# ?补充条件判断: if k in cost:
if # ?: if float(v)<cost[k]:
# ?更新价钱 cost[k]=float(v)
print(k+'降价了,现价'+v+'元') print(k+'降价了,现价'+v+'元')
else: else:
print(k+'涨价了,我们不买') print(k+'涨价了,我们不买')
else: else:
cost[k] = float(v) cost[k] = float(v)
print(k+'的价钱'+v+'元已上传~') print(k+'的价钱'+v+'元已上传~')
#魏诗航
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment