建筑兔零基础python自学记录117|数据处理(2)-21

总结:

排序 A.sort() 降序排A.sort(reverse=True)

最大值 max() 最小值 min()

求和sum()

平均值=sum()/len()

通用模板:

i=0
student_scores=[]

while i<6:
    score=int(input())
    student_scores.append(score)
    i=i+1

i = 0
scores = []  # 定义空列表
while i<6   :   # 在这里写循环成立的条件
    score = int(input())   # 在这里通过 input() 函数获取输入的数据
    scores.append(score)   # 在这里将 score 添加至 scores 列表中
    i+=1         # 不要忘了控制 i 的值哦

print(scores)

另一种算法(直接用sum()和len()求和和求平均值:

i=0
student_scores=[]

while i<6:
    score=int(input())
    student_scores.append(score)
    i=i+1

total=sum(student_scores)
average=total/len(student_scores)

print(total)
print(average)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值