新月 2023-04-18 14:15 采纳率: 100%
浏览 21
已结题

需要解答python

img

img


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

  • 写回答

1条回答 默认 最新

  • Dick_不周 2023-04-18 15:07
    关注

    好消息是,图片可以避免被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))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 4月26日
  • 已采纳回答 4月18日
  • 创建了问题 4月18日

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错