字典+D={"张三":88,"李四":90,"王五":73,"赵六":82},写出下列操作的代码。 (1)向字典中添加键值对“"钱七":90” (2)修改"王五"对应的值为93 (3)删除"赵六"对应
时间: 2023-12-02 13:43:11 浏览: 37
以下是对应操作的代码:
```python
# 定义字典
D = {"张三":88,"李四":90,"王五":73,"赵六":82}
# 添加键值对
D["钱七"] = 90
# 修改键值对
D["王五"] = 93
# 删除键值对
del D["赵六"]
# 输出字典
print(D)
```
输出结果为:`{'张三': 88, '李四': 90, '王五': 93, '钱七': 90}`
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![m](https://img-home.csdnimg.cn/images/20210720083646.png)
![m](https://img-home.csdnimg.cn/images/20210720083646.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)