Commit d957fee1 by BellCodeEditor

auto save

parent 493a98ab
student1 = {'语文': 91, '数学': 88, '英语': 85}
student2 = {'语文': 97, '数学': 98, '英语': 90}
student3 = {'语文': 95, '数学': 100, '英语': 93}
score = {'悟空': student1, '诺依': student2, '小贝': student3}
while True:
print("请输入要查询的名字,退出请输入q")
name = input("姓名:")
if name in score:
info = score[name]
for k,v in info.items():
print(k, v)
print("*" * 30)
elif name == "q":
break
else:
print("查询错误,请重新输入")
print("程序结束")
\ No newline at end of file
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
scores = {'语文':89, '数学':95, '英语':80} scores = {'语文':89, '数学':95, '英语':80}
def get_average(scores): def get_average(scores):
score = 0 sumscore = 0
for subject, score in scores.items(): for subject, score in scores.items():
score += score sumscore += score
print('现在的总分是%d'%score) print('现在的总分是%d'%sumscore)
ave_score = score/len(scores) ave_score = sumscore/len(scores)
print('平均分是%d'%ave_score) print('平均分是%d'%ave_score)
get_average(scores) get_average(scores)
\ No newline at end of file
import turtle
import turtle
pen=turtle.Pen()
screen=turtle.Screen()
pen.speed("fast")#pen.speed(90)
pen.hideturtle()
screen.bgcolor('black')
i=0
while i<135:
pen.pencolor('pink')
pen.penup()
pen.goto(0,0)
pen.forward(200)
pen.pendown()
pen.circle(100)
pen.left(2)
i+=1
turtle.done()
\ No newline at end of file
while True:
if name in score:
info=score[name]
for i,j in info.items():
print("*"*100)
print(i,j)
elif name="q":
break
else:
print("名字不对")
\ No newline at end of file
scores1 = {'语文':89, '数学':95, '英语':80}
scores1 = {'语文':89, '数学':95, '英语':80}
scores2 = {'语文':68, '数学':64, '英语':76}
def average(scores):#scores是函数的参数
total = 0 # sum 作为函数内部的局部变量,从而可以为函数所用
for k, v in scores.items():
total += v
print('现在的总分是%d'%total)
ave_score = total/len(scores)
print('平均分是%d'%ave_score)
average(scores2)#调用函数
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