【判断题】
包含yield语句的函数一般成为生成器函数,可以用来创建生成器对象。
A. 对
B. 错
查看试卷,进入试卷练习
微信扫一扫,开始刷题
答案
A
解析
暂无解析
相关试题
【判断题】
在函数中yield语句的作用和return完全一样。
A. 对
B. 错
【判断题】
Python内置的字典dict中元素是按添加的顺序依次进行存储的。
A. 对
B. 错
【判断题】
Python内置的集合set中元素顺序是按元素的哈希值进行存储的,并不是按先后顺序。
A. 对
B. 错
【判断题】
已知x = {1:1, 2:2},那么语句x[3] =3无法正常执行。
A. 对
B. 错
【判断题】
Python内置字典是无序的,如果需要一个可以记住元素插入顺序的字典,可以使用collections.OrderedDict。
A. 对
B. 错
【判断题】
语句pass仅起到占位符的作用,并不会做任何操作。
A. 对
B. 错
【判断题】
在条件表达式中不允许使用赋值运算符“=”,会提示语法错误。
A. 对
B. 错
【判断题】
任何包含call()方法的类的对象都是可调用的。
A. 对
B. 错
【判断题】
在Python中函数和类都属于可调用对象。
A. 对
B. 错
【判断题】
无法使用lambda表达式定义有名字的函数。
A. 对
B. 错
【判断题】
已知x是一个列表,那么x = x[3:] + x[:3]可以实现把列表x中的所有元素循环左移3位。
A. 对
B. 错
【判断题】
已知x和y是两个字符串,那么表达式sum((1 for i,j in zip(x,y) if i==j))可以用来计算两个字符串中对应位置字符相等的个数。
A. 对
B. 错
【判断题】
函数和对象方法是一样的,内部实现和外部调用都没有任何区别。
A. 对
B. 错
【判断题】
在设计派生类时,基类的私有成员默认是不会继承的。
A. 对
B. 错
【判断题】
如果在设计一个类时实现类len()方法,那么该类的对象会自动支持Python内置函数len()。
A. 对
B. 错
【判断题】
Python 3.x中字符串对象的encode()方法默认使用utf8作为编码方式。
A. 对
B. 错
【判断题】
已知x = ‘hellow world.’.encode(),那么表达式x.decode(‘gbk’)的值为’hellow world.’。
A. 对
B. 错
【判断题】
已知x = ‘Python是一种非常好的编程语言’.encode(),那么表达式x.decode(‘gbk’)的值为’Python是一种非常好的编程语言’。
A. 对
B. 错
【判断题】
正则表达式’^http’只能匹配所有以’http’开头的字符串。
A. 对
B. 错
【判断题】
正则表达式’^\d{18}|\d{15}$’只能检查给定字符串是否为18位或15位数字字符,并不能保证一定是合法的身份证号。
A. 对
B. 错
【判断题】
二进制文件也可以使用记事本程序打开,只是无法正确阅读和理解其中的内容。
A. 对
B. 错
【判断题】
正则表达式’[^abc]’可以一个匹配任意除’a’、’b’、’c’之外的字符。
A. 对
B. 错
【判断题】
正则表达式’python|perl’或’p(ython|erl)’都可以匹配’python’或’perl’。
A. 对
B. 错
【判断题】
文本文件是可以迭代的,可以使用for line in fp类似的语句遍历文件对象fp中的每一行。
A. 对
B. 错
【判断题】
Python的主程序文件python.exe属于二进制文件。
A. 对
B. 错
【判断题】
使用记事本程序也可以打开二进制文件,只不过无法正确识别其中的内容。
A. 对
B. 错
【判断题】
对字符串信息进行编码以后,必须使用同样的或者兼容的编码格式进行解码才能还原本来的信息。
A. 对
B. 错
【判断题】
使用pickle进行序列化得到的二进制文件使用struct也可以正确地进行反序列化。
A. 对
B. 错
【判断题】
已知当前文件夹中有一个文件readme.txt具有只读属性,假设标准库os已正确导入,那么可以通过语句os.chmod(‘readme.txt’, 0o777)来删除该文件的只读属性。
A. 对
B. 错
【判断题】
Python标准库os的函数remove()不能删除具有只读属性的文件。
A. 对
B. 错
【判断题】
字节串b’hello world’和b’hello world.’的MD5值相差很小。
A. 对
B. 错
【判断题】
由于异常处理结构try…except…finally…中finally里的语句块总是被执行的,所以把关闭文件的代码放到finally块里肯定是万无一失,一定能保证文件被正确关闭并且不会引发任何异常。
A. 对
B. 错
【判断题】
使用TCP协议进行通信时,必须首先建立连接,然后进行数据传输,最后再关闭连接。
A. 对
B. 错
【判断题】
TCP是可以提供良好服务质量的传输层协议,所以在任何场合都应该优先考虑使用。
A. 对
B. 错
【判断题】
在4核CPU平台上使用多线程编程技术可以很轻易地获得400%的处理速度提升。
A. 对
B. 错
【判断题】
多线程编程技术主要目的是为了提高计算机硬件的利用率,没有别的作用了。
A. 对
B. 错
【填空题】
1、 Python安装扩展库常用的是_工具。___
【填空题】
2、 Python标准库math中用来计算平方根的函数是____。___
【填空题】
3、 Python程序文件扩展名主要有__和两种,其中后者常用于GUI程序。___
【填空题】
4、 Python源代码程序编译后的文件扩展名为___。___
推荐试题
【单选题】
In the race, it looked as if he would be the first, but then another young man who was close behind him put on speed and ___ by a few seconds.
A. beat him for it
B. beat him to it
C. beat him up
D. beat it to him
【单选题】
It is really helpful to have someone like you that we can ___ and count on during difficult times.
A. lean on
B. get to
C. hang on
D. get by
【单选题】
Women have a greater ability to ___ names with faces than men do, and they are also better at recalling lists.
A. associate
B. compare
C. engage
D. involve
【单选题】
He was always ready to help others and managed to ___ his friends ____being hurt.
A. expose … to
B. confine …to
C. restrict … from
D. shield … from
【单选题】
Older people are less likely to be ___ their negative emotions (情绪) and more likely to focus on the positive.
A. reserved for
B. caught up in
C. beat up to
D. counted on
【单选题】
I don’t have any bandage, so I have to ___ pressure to the wound to keep the bleeding down.
A. apply
B. involve
C. fulfill
D. establish
【单选题】
It is important that whichever candidate (候选人) is picked the loser should accept the defeat ___.
A. in advance
B. with great pride
C. with good grace
D. in large part
【单选题】
___ that new homes cost more than older homes, but that is not true across the country anymore.
A. It used to be
B. It is used to be
C. It used to being
D. It is used to being
【单选题】
The boss ___ his employees to work longer hours as the company is dreadfully short of staff at present.
A. called on
B. signed up
C. cared for
D. set up
【单选题】
The president’s visit and ___ discussions led to a plan that aimed to improve the trade relations between the two countries.
A. emerging
B. subsequent
C. consequent
D. Submerging
【单选题】
The author ___ his general idea mainly through statistics and results obtained from a survey (调查) about auto customer services in the United States.
A. assumes
B. engages
C. illustrates
D. represents
【单选题】
People in this town starved, several buildings were bombed and crime ___ because you had to steal to eat.
A. eroded
B. reflected
C. released
D. soared
【单选题】
Olympic recognition for bodybuilding (健美) remains ___ since some argue that bodybuilding is not a sport because the actual contest does not involve the same sort of efforts as “real” sports.
A. controversial
B. conventional
C. characteristic
D. influential
【单选题】
Tom tried to justify his absence from the meeting by ___ that he had been ill that day.
A. admitting
B. advocating
C. claiming
D. citing
【单选题】
___ the huge financial benefits, biological companies have been rushing to set up laboratories and new research projects.
A. Aware
B. Aware of
C. Not aware
D. Not aware of
【单选题】
Unfortunately, ___ lack of funds, the studies he began just two months ago, had to be ended early.
A. out of
B. in addition to
C. owing to
D. to begin with
【单选题】
With a good command of English, he soon got ___ to working with British people.
A. accustomed
B. consistent
C. relevant
D. responsible
【单选题】
What needs to be ___ here is that language and culture interact, and that understanding of one requires understanding of the other.
A. altered
B. stressed
C. aroused
D. committed
【单选题】
Policies and organizations must be created to meet workers’ hopes, and to ___ new problems that inevitably arise between workers and managers.
A. compromise
B. ensure
C. undermine
D. resolve
【单选题】
To keep the wheels of industry turning, we produce consumer goods in endless quantities, and, in the process, are rapidly ___ our natural resources.
A. ignoring
B. collapsing
C. enduring
D. exhausting
【单选题】
As a person who loves peace, he is committed ___ realizing peace between countries.
A. of
B. about
C. for
D. to
【单选题】
Learning how to use chopsticks is easy for me, ___ learning how to conduct myself at the table is quite difficult.
A. whereas
B. however
C. therefore
D. besides
【单选题】
___ that the patient smokes 50 cigarettes a day, it would be reasonable to assume there is some lung damage.
A. To give
B. Giving
C. Given
D. Having given
【单选题】
Kenyan (肯尼亚的) women tend to vote for those who could provide them ___ the necessary food to live on.
A. of
B. with
C. for
D. about
【单选题】
___ all obstacles and failures, the scientist continued doing his experiments day and night.
A. In spite of
B. In contrast to
C. As a matter of
D. As a result of
【单选题】
I’m willing to ___ that a larger car would have cost more, but I still think we should have bought one.
A. withdraw
B. indicate
C. abandon
D. concede
【单选题】
Manufacturing (制造) companies spend millions of pounds on advertisements, trying to ___ customers that their products are better than those of other companies.
A. confine
B. convince
C. depress
D. reconcile
【单选题】
He is not the right person for the project: he is not very technically minded and ___, he does not have the sense of responsibility.
A. instead
B. yet
C. furthermore
D. nevertheless
【单选题】
Death rates declined in many places, partly because of the ___ in hunger.
A. decrease
B. myth
C. obstacle
D. burden
【单选题】
In deciding whether or not a situation is safe, pilots must be taught to assume that the worst will happen, and then to ___ whether there is a risk or not.
A. absorb
B. apply
C. assess
D. occupy
【单选题】
The worker was not worried as he knew that if he gave up the job, there would be ___ opportunities for him to work somewhere else.
A. formative
B. marginal
C. vigorous
D. numerous
【单选题】
The research shows the region might ___ overheating (经济过热), but the policymakers so far appear to be relatively relaxed about the future of the economy.
A. catch a glimpse of
B. be at risk of
C. take a toll on
D. be free from
【单选题】
Measures have been taken to ensure that no student will have to ___ of college for economic reasons.
A. lay out
B. cancel out
C. drop out
D. stand out
【单选题】
Stress that is not treated can lead to significant medical illnesses, which ___ can lead to greater stress and even depression (抑郁症).
A. after all
B. in turn
C. on the contrary
D. at least
【单选题】
Narcissism (自恋) has its benefits in terms of self-belief and confidence, but it also tends to be ___ risky decision-making.
A. associated with
B. contrasted with
C. reserved for
D. relieved of
【单选题】
When Tom saw his doctor again, she suggested that maybe a more substantial lunch, like a sandwich, might ___ his desire to have snacks in the afternoon.
A. count on
B. cut back on
C. hold on to
D. contribute to
【单选题】
You shouldn’t ___ – let your children make their own decisions.
A. interact
B. abuse
C. startle
D. interfere
【单选题】
This is a huge and difficult project and if you take it up, you ___ many difficulties.
A. like to encounter
B. like encountering
C. are likely to encounter
D. are like to encounter
【单选题】
The ability to live for a long time without water is characteristic ___ the camel.
A. of
B. for
C. about
D. in
【单选题】
Rising sales is a good ___ that this product is well received in the market.
A. response
B. convention
C. indication
D. Influence