欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

python第三次作业——叶耀宗

程序员文章站 2023-01-13 08:38:29
作业1import random#引入随机数模块xing=["小白","小黄","小王","小陈","小绿"]print("学号\t\t\t姓名\t\tJava\tC语言\tPython\t平均成绩\t")listj=[]listc=[]listp=[]lista=[]for i in range(... ......

作业1

import random
#引入随机数模块
xing=["小白","小黄","小王","小陈","小绿"]
print("学号\t\t\t姓名\t\tjava\tc语言\tpython\t平均成绩\t")
listj=[]
listc=[]
listp=[]
lista=[]
for i in range(5):
#循环5次
n = 20170000 + random.randint(0, 9999)
j = random.randint(60, 100)
listj.append(j)
#放在数组最末端
c = random.randint(60, 100)
listc.append(c)
p = random.randint(60, 100)
listp.append(p)
ave = (j + c + p) / 3
print("%d\t%s\t\t%d\t\t%d\t\t%d\t\t%.2f" % (n, xing[i], j, c, p, ave))

ja = listj[0] + listj[1] + listj[2] + listj[3] + listj[4]
ja = ja / 5
lista.append(ja)
print(" java平均成绩:", format(ja))
ca = listc[0] + listc[1] + listc[2] + listc[3] + listc[4]
ca = ca / 5
lista.append(ca)
print(" c语言平均成绩:", format(ca))
pa = listp[0] + listp[1] + listp[2] + listp[3] + listp[4]
pa = pa / 5
lista.append(pa)
print("python平均成绩:", format(pa))
max = max(lista)
min = min(lista)
print("最大值为:{}\n最小值为{}".format(max, min))

python第三次作业——叶耀宗

 

作业2:
def tempconvert():
t = input("请输入数值:")
r = ["rmb","rmb"]
u = ["usd","usd"]
try:
eval(t[3:])
except nameerror:
print("错误,第四位开始请输入整数")
if t[0:3] in r:
temp = float(t[3:])/6
temp = "{:.2f}".format(temp)
temp = "usd" + str(temp)
print("结果:",temp)
elif t[0:3] in u:
temp = float(t[3:])*6
temp = "{:.2f}".format(temp)
temp = "rmb" + str(temp)
print("结果:",temp)
else:
print("输入格式错误")
return false
return temp


tempconvert()

python第三次作业——叶耀宗

python第三次作业——叶耀宗