其他分享
首页 > 其他分享> > 数组的加减

数组的加减

作者:互联网

a = [0,1,2,3,4]
b = [2,3,4,5,7]
# 用于储存a,b数组的加减结果
r = []
re = []
i = 0
# len(数组长度)
while(i < len(a)):
    add = a[i] + b[i]
    sub = a[i] - b[i]
    # 每次结果储存到r re里
    r.append(add)
    re.append(sub)
    i = i + 1
print('a+b =',r)
print('a-b =',re)

 

标签:sub,加减,len,re,add,数组,print
来源: https://www.cnblogs.com/xiaobaixuecheng101/p/16490094.html