题目详情
单选题 已知字典 dic={'小欣':90, '小蕊':92, '小微':87},存放了学生的姓名及成绩.假设变量user存放了某学生的姓名,则以下哪个程序不能够实现功能:在字典中查询该学生信息是否存在,如果存在,输出其成绩,否则输出'该学生不存在!(2.0)
A. if dic.count(user)==0: print('该学生不存在!') else: print(dic[user])
B. if user not in dic: print('该学生不存在!') else: print(dic[user])
C. if user in dic: print(dic[user]) else: print('该学生不存在!')
D. if dic.get(user,'error')=='error': print('该学生不存在!') else: print(dic[user])

学科:Python 23级本科
时间:2023-11-06 00:28:27
相关题目
相关作业
