python语言关键字在异常处理结构中_python二级考试试题6

C出错D正确答案:22.以下选项能改变 turtle 画笔的颜色是:Aturtle.colormode()Bturtle.setup()Cturtle.pd()Dturtle.pencolor()正确答案:23.以下程序的不可能输出结果是:from random import *print(sample({1,2,3,4,5},2))A[5, 1]B[1, 2]C[4, 2]D[1, 2, 3]正确答案:从前面那个取两个数出来24.以下程序的输出结果是:import timet = time.gmtime()print(time.strftime("%Y-%m-%d %H:%M:%S",t))A系统当前的日期B系统当前的时间C系统出错D系统当前的日期与时间正确答案:25.函数表达式 all([1,True,True]) 的结果是:A无输出BFalseC出错DTrue正确答案:26.以下关于 Python 函数对变量的作用,错误的是:A简单数据类型在函数内部用global保留字声明后,函数退出后该变量保留B全局变量指在函数之外定义的变量,在程序执行全过程有效C简单数据类型变量仅在函数内部创建和使用,函数退出后变量被释放D对于组合数据类型的全局变量,如果在函数内部没有被真实创建的同名变量,则函数内部不可以直接使用并修改全局变量的值正确答案:27.以下程序的输出结果是:ls = ["浣熊","豪猪","艾草松鸡","棉尾兔","叉角羚"]x = "豪猪"print(ls.index(x,0))A0B-4C-3D1正确答案:28.以下属于 Python 脚本程序转变为可执行程序的第三方库的是:AopenpyxlBPyPDF2CpillowDpyinstaller正确答案:29.以下属于 Python 中文分词方向第三方库的是:Apython-docxBpython-pptxCpefileDjieba正确答案:30.以下生成词云的 Python 第三方库的是:AcsvkitBPydubCmoviepyDwordcloud正确答案:31.假设将单词保存在变量 word 中,使用一个字典类型 counts={},统计单词出现的次数可采用以下代码:Acounts[word] = count[word] + 1Bcounts[word] = 1Ccounts[word] = count.get(word,1) + 1Dcounts[word] = count.get(word,0) + 1正确答案:32.以下程序的输出结果是:lcat =["狮子","猎豹","虎猫","花豹","孟加拉虎","美洲豹","雪豹"]for s in lcat: if "豹" in s: print(s,end="") continueA猎豹花豹美洲豹雪豹B猎豹C雪豹D猎豹花豹美洲豹雪豹正确答案:33.以下程序的输出结果是:s1 ="袋鼠"print("{0}生活在主要由母{0}和小{0}组成的较小的群体里。".format(s1))ATypeError: tuple index out of rangeB{0}生活在主要由母{0}和小{0}组成的较小的群体里。CIndexError: tuple index out of rangeD袋鼠生活在主要由母袋鼠和小袋鼠组成的较小的群体里。正确答案:34.以下程序的输出结果是:s1 ="企鹅"s2 ="超级游泳健将"print("{0:^4}:{1:!<9}".format(s1,s2))A企鹅:超级游泳健将!!!B企鹅 :超级游泳健将!!!C企鹅 :!超级游泳健将!!D企鹅:超级游泳健将!!!正确答案:35.以下程序的输出结果是:for num in range(1,4): sum *= numprint(sum)A6B7C7.0DTypeError出错 正确答案:Sum都没有赋值或者定义36.以下程序的输出结果是:ls = ["石山羊","一角鲸","南极雪海燕","竖琴海豹","山蝰"]ls.remove("山蝰")str = ""print("极地动物有",end="")for s in ls: str = str + s + ","print(str[:-1],end="。")A极地动物有石山羊,一角鲸,南极雪海燕,竖琴海豹,山蝰B极地动物有石山羊,一角鲸,南极雪海燕,竖琴海豹,山蝰。C极地动物有石山羊,一角鲸,南极雪海燕,竖琴海豹D极地动物有石山羊,一角鲸,南极雪海燕,竖琴海豹。正确答案:37.以下程序的输出结果是:for i in "Summer": if i == "m": break print(i)AmBmmCmmerD无输出正确答案:循环已经退出38.以下关于字典的描述,错误的是:A字典中元素以键信息为索引访问B字典长度是可变的C字典是键值对的集合D字典中的键可以对应多个值信息正确答案:39.以下文件操作方法中,打开后能读取 CSV 格式文件的选项是:Afo = open("123.csv","w")Bfo = open("123.csv","x")Cfo = open("123.csv","a")Dfo = open("123.csv","r")正确答案:40.以下程序的功能是:s = "What\s a package, project, or release?We use a number of terms to describe software available on PyPI, like project, release, file, and package. Sometimes those terms are confusing because they\re used to describe different things in other contexts. Heres how we use them on PyPI:A project on PyPI is the name of a collection of releases and files, and information about them. Projects on PyPI are made and shared by other members of the Python community so that you can use them.A release on PyPI is a specific version of a project. For example, the requests project has many releases, like requests 2.10 and requests 1.2.1. A release consists of one or more files.A file, also known as a package, on PyPI is something that you can download and install. Because of different hardware, operating systems, and file formats, a release may have several files (packages), like an archive containing source code or a binary wheel."s = s.lower()for ch in \,?.:(): s = s.replace(ch," ")words = s.split()counts = {}for word in words: counts[word] = counts.get(word,0)+1items = list(counts.items())items.sort(key=lambda x:x[1],reverse = True)fo = open("wordnum.txt","w",encoding ="utf-8")for i in range(10): word,count = items[i] fo.writelines( word + ":" + str(count) + "\n")fo.close()A统计字符串s中所有单词的出现次数,将单词和次数写入wordnum.txt文件B统计字符串s中所有字母的出现次数,将单词和次数写入wordnum.txt文件C统计输出字符串s中前10个字母的出现次数,将单词和次数写入wordnum.txt文件D统计字符串s中前10个高频单词的出现次数,将单词和次数写入wordnum.txt文件正确答案:18欢迎下载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值