3、气象局使用元组(tuple)记录了某市过去一周的最高温度和最低温度:最高温度:30, 28, 29, 31, 33, 35, 32最低温度:20, 21, 19, 22, 23, 24, 20请列出过去一周的最高温度、最低温度和平均温度。python
时间: 2023-06-08 11:06:38 浏览: 123
代码如下:
```
high_temperatures = (30, 28, 29, 31, 33, 35, 32)
low_temperatures = (20, 21, 19, 22, 23, 24, 20)
# 计算最高温度、最低温度和平均温度,并输出结果
max_temperature = max(high_temperatures)
min_temperature = min(low_temperatures)
avg_temperature = (sum(high_temperatures) + sum(low_temperatures)) / 14
print("过去一周的最高温度是:", max_temperature)
print("过去一周的最低温度是:", min_temperature)
print("过去一周的平均温度是:", avg_temperature)
```
阅读全文