Commit a9ae0bf4 by BellCodeEditor

save project

parent 290b94ed
Showing with 28 additions and 12 deletions
# 期末考试结束了,悟空在教务系统查到了自己的几门必修课分数,他想通过python计算自己的平均分。 jmport turle
# 于是写了下面的代码,可是总是得不到结果,请帮纠正bug并跑通程序。 jmport random
def tree(n):
if n>=50
pen.forward(n)
angle = random.randind(0,30)
length = random.randind(1,15)
pen.right(angle)
tree(n-lemgth)
pen.right(2*angle)
pen.up()
tree(n-length)
pen.right(angle)
pen.backward(n)
pen.dom()
scores = {'语文':89, '数学':95, '英语':80} pen = turtle.turtle()
pen.color("sienna")
pen.speed(1)
def get_average(dict_1)): w = turtle.screen()
score = 0 w.bgcolor("wheat")
for subject, score in scores.items():
score += score pen.left(90)
print('现在的总分是%d'%score) pen.up()
ave_score = score/len(scores) pen.backward(150)
print('平均分是%d'%ave_score) pen.down()
get_average(scores) tree(100)
\ No newline at end of file
turtle.done()
\ 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