需要解答python

img

img


大一文科python学不懂,想我来个热心人士解答问题 ,非常感谢

好消息是,图片可以避免被AI识别。
坏消息是,图片还是歪的!

nations = dict(zip(['China','France','USA','Germany'],['Chinese','French','English','German']))
for key,value in nations.items():
    print(key)   ### 显示所有键
print('华丽分割线----------')
for key,value in nations.items():
    print(value)   ### 显示所有值
print('华丽分割线----------')
print(nations)     ### 所有项
print('华丽分割线----------')
print('获取键France对应的值为:',nations['France'])
new_diction = {'Spain':'Spanish' , 'Japan':'Japanese'}   ### 构建一个新字典
for key,value in new_diction.items() :
    nations[key] = value        ####添加进 nations中
#----------------------------------------------------------      第二题
names = ['xiaoma','xiaoma','xiaowang','xiaoma','xiaoliu','xiaoliu']
##统计出每个学生参与的次数
students = set(names)      ### 所有不重复的学生
result = dict()
for student in students :
    result[student] = 0  ### 学生出现次数置0
for name in names :
     result[name] += 1   ###  +1
print(result)
# -----------------第三题
users = {'name':'password','name1':'password1'}
notin = True
for key,value in users.items():
    if 'xiaowang' == key :
        notin = False
        print(users[key]) ### 如果存在输出密码
        break
if notin :
    print('not found')     ### 不存在输出没找到

#-----------------------------------第四题
footballset = set(['a','b','c','d'])
basketballset = set(['e','f','n','mm','a'])
def count_set(set_a):
    i = 0
    for tmp in set_a :
        i += 1
    return i
print(footballset , count_set(footballset))
print(basketballset,count_set(basketballset))
tichu_list = []
for a in footballset :
    for b in basketballset :
        if a == b :
            tichu_list.append(a)
result = []
for a in footballset :
    if a not in tichu_list :
        result.append(a)
for b in basketballset :
    if b not in tichu_list :
        result.append(b)
print('只选了一门课的人有 :',result)
print('总人数为:',len(result))