水果店营业额七天分别为43,55,29,35,31,104,122,使用循环语句的方式将营业额录入列表,并输出周内营业额与周末营业额差值
时间: 2023-05-30 09:07:23 浏览: 56
sales = [43, 55, 29, 35, 31, 104, 122]
weekday_sales = 0
weekend_sales = 0
for i in range(len(sales)):
if i < 5: # 周内
weekday_sales += sales[i]
else: # 周末
weekend_sales += sales[i]
print("周内营业额:", weekday_sales)
print("周末营业额:", weekend_sales)
print("周末营业额与周内营业额差值:", weekend_sales - weekday_sales)
阅读全文