【判断题】
假设random模块已导入,那么表达式 random.sample(range(10), 7) 的作用是生成7个不重复的整数。
A. 对
B. 错
查看试卷,进入试卷练习
微信扫一扫,开始刷题
答案
A
解析
暂无解析
相关试题
【判断题】
在Python 3.x中reduce()是内置函数。
A. 对
B. 错
【判断题】
以读模式打开文件时,文件指针指向文件开始处。
A. 对
B. 错
【判断题】
以追加模式打开文件时,文件指针指向文件尾。
A. 对
B. 错
【判断题】
已知x = (1, 2, 3, 4),那么执行x[0] = 5之后,x的值为(5, 2, 3, 4)。
A. 对
B. 错
【判断题】
已知x = 3,那么执行x += 6语句前后x的内存地址是不变的。
A. 对
B. 错
【判断题】
成员测试运算符in作用于集合时比作用于列表快得多。
A. 对
B. 错
【判断题】
在Python 3.x中,使用内置函数input()接收用户输入时,不论用户输入的什么格式,一律按字符串进行返回。
A. 对
B. 错
【判断题】
安装Python扩展库时只能使用pip工具在线安装,如果安装不成功就没有别的办法了。
A. 对
B. 错
【判断题】
使用random模块的函数randint(1, 100)获取随机数时,有可能会得到100。
A. 对
B. 错
【判断题】
如果只需要math模块中的sin()函数,建议使用from math import sin来导入,而不要使用import math导入整个模块。
A. 对
B. 错
【判断题】
已知列表x = [1, 2, 3, 4],那么表达式x.find(5)的值应为-1。
A. 对
B. 错
【判断题】
列表对象的排序方法sort()只能按元素从小到大排列,不支持别的排序方式。
A. 对
B. 错
【判断题】
g = lambda x: 3不是一个合法的赋值表达式。
A. 对
B. 错
【判断题】
内置函数len()返回指定序列的元素个数,适用于列表、元组、字符串、字典、集合以及range、zip等迭代对象。
A. 对
B. 错
【判断题】
已知x和y是两个等长的整数列表,那么表达式sum((i*j for i, j in zip(x, y)))的作用是计算这两个列表所表示的向量的内积。
A. 对
B. 错
【判断题】
已知x和y是两个等长的整数列表,那么表达式[i+j for i,j in zip(x,y)]的作用时计算这两个列表所表示的向量的和。
A. 对
B. 错
【判断题】
表达式int(‘1’*64, 2)与sum(2**i for i in range(64))的计算结果是一样的,但是前者更快一些。
A. 对
B. 错
【判断题】
已知x = list(range(20)),那么语句del x[::2]可以正常执行。
A. 对
B. 错
【判断题】
已知x = list(range(20)),那么语句x[::2] = []可以正常执行。
A. 对
B. 错
【判断题】
已知x = list(range(20)),那么语句print(x[100:200])无法正常执行。
A. 对
B. 错
【判断题】
已知x是个列表对象,那么执行语句y = x之后,对y所做的任何操作都会同样作用到x上。
A. 对
B. 错
【判断题】
已知x是个列表对象,那么执行语句y = x[:]之后,对y所做的任何操作都会同样作用到x上。
A. 对
B. 错
【判断题】
在Python中,变量不直接存储值,而是存储值的引用,也就是值在内存中的地址。
A. 对
B. 错
【判断题】
表达式(i**2 for i in range(100))的结果是个元组。
A. 对
B. 错
【判断题】
在Python中元组的值是不可变的,因此,已知x = ([1], [2]),那么语句x[0].append(3)是无法正常执行的。
A. 对
B. 错
【判断题】
包含yield语句的函数一般成为生成器函数,可以用来创建生成器对象。
A. 对
B. 错
【判断题】
在函数中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. 错
推荐试题
【单选题】
- Is John there?____
A. Speaking.
B. I'm not Mary.
C. Who are you?
D. Mary is well today.
【单选题】
- Would you like to join us for Sunday dinner____
A. It's nice of you to invite me.
B. How about the food?
C. I like onion soup.
D. I'm sorry I missed the fun last time.
【单选题】
- Could you tell me where the nearest parking lot is?____
A. Don't ask me.
B. Parking is very difficult.
C. Sorry, I'm a stranger here.
D. Sorry, you can't park here.
【单选题】
- Sorry, ___
A. here you are.
B. take it.
C. it's taken.
D. never mind.
【单选题】
-What's this in English? ____
A. It's a map.
B. That is a map.
C. Yes, it's a map.
D. No, it isn't.
【单选题】
- I hear you got through your exam. Congratulations!____
A. No. I didn't do well enough.
B. Who told you that?
C. Thanks.
D. Yes, I got a good mark.
【单选题】
- Don't forget to come to my party this evening!___
A. I can't.
B. I won't.
C. I don't.
D. I will.
【单选题】
- Jim, please don't put your head out of the window on the bus. It's dangerous!___
A. Good idea.
B. Sorry, I won't do it again.
C. It doesn't matter.
D. It's good.
【单选题】
-How about going fishing?___, I have no patience for that.
A. Excuse me
B. Sorry
C. Pardon
D. Apologize
【单选题】
- Thanks for the lovely and delicious food______.
A. No thanks
B. Never mind
C. All right
D. My pleasure
【单选题】
- Haven't seen you for ages. Let's have a get-together next week._____
A. Great idea.
B. Welcome!
C. Yes, of course.
D. No, thanks.
【单选题】
- Do you mind if I switch off the radio? ______. Go ahead.
A. Never mind
B. No way
C. No, not at all
D. No, you'd better not
【单选题】
- Could I use your bike for a moment? ___
A. It's well.
B. It doesn't matter.
C. By all means.
D. I have no idea.
【单选题】
-How do you like the story?_______.
A. I'd like to read it
B. I like it very much
C. fine, thank you
D. It's very interesting
【单选题】
- I'll sorry to trouble you.______.
A. Don't say so
B. OK
C. It doesn't matter
D. That's fight
【单选题】
- We ordered 20 boxes of your products, but we have only got 19. - ____
A. You do not have to.
B. It does not matter.
C. We will send another tomorrow.
D. Nothing serious.
【单选题】
--Will you please give the note to him? _________.
A. Certainly, I'll give it to him
B. No, please not
C. Sorry, I don't
D. Yes, please do
【单选题】
- Thank you ever so much for your lovely gift____
A. Never mind
B. I'm glad you like it.
C. Please don't say so.
D. No, It's not so good.
【单选题】
- I'd like to invite you to dinner this Saturday, Mr. Smith.____
A. Oh, no. let's not.
B. I'd rather stay at home.
C. I'm sorry, but I have other plans.
D. Oh, no. That'll be too much trouble.
【单选题】
- Could you please open the window?____
A. I can't.
B. Go ahead.
C. Sure.
D. It's really very kind.
【单选题】
- Do you think I can borrow your bike for a few hours?____
A. I'm afraid you can.
B. I'm sorry, but I really need it this afternoon.
C. Yes, I don't think so.
D. I'll think about it later.
【单选题】
- Thank you very much for the dictionary you sent me.____
A. No thanks.
B. I'm glad you like it.
C. Please don't say so.
D. No, it's not so good.
【单选题】
- How do you like the movie we saw yesterday?____
A. You are welcome.
B. How about you?
C. I've never seen a better movie than it.
D. It is very expensive.
【单选题】
- What do you think of your new teacher____
A. He came to teach us last week.
B. He teaches us English.
C. He has two children.
D. He is very nice.
【单选题】
- Are you going to have a holiday?____
A. Not until next week.
B. Three weeks ago.
C. To Beijing.
D. I'm pleased to hear that.
【单选题】
- You seem to be lost. Need help? ____
A. Yes, would you please help me with the bag?
B. Help me find my key, please.
C. Yes, with pleasure.
D. I'm looking for Zhongshan Road.
【单选题】
- Can you help me clear up the mess____
A. Yes, it doesn't matter.
B. No, that's OK.
C. Yes, help yourself.
D. No problem.
【单选题】
- Does No.20 bus stop at our school?____
A. I go to school by bus.
B. I'm afraid not.
C. You are welcome.
D. I'll not take No.20 bus.
【单选题】
- Can I help you? ____
A. Sorry, I don't need your help.
B. What help can you give us?
C. I'd like to try on these shoes, please.
D. Thanks. You are welcome.
【单选题】
- Sorry to have kept you waiting. ____
A. That's OK.
B. What are you doing?
C. What's wrong with you?
D. Where have you been?
【单选题】
- What is she?____
A. She is a typist.
B. She is talking to her friend.
C. She is having a holiday.
D. She is my sister.
【单选题】
- That's a beautiful cat. I wonder who it belongs to.____
A. It belongs to the
B. rowns. B.The cat is my favourite too.
C. Mind your own business.
D. I can't say anything more.
【单选题】
- Excuse me, could you tell me the time____
A. You'd better buy a watch.
B. It's three thirty by my watch.
C. Can you see the clock?
D. It's late I think.
【单选题】
- What do you think of the movie we saw last night?____
A. The actress is bad.
B. Terrific!
C. The theatre is bad.
D. Nobody was there.
【单选题】
___ No, thanks. I'm just looking around. I'll let you know if I want anything.
A. Could you help me?
B. What will you buy?
C. Can I help you?
D. Do you like to look around?
【单选题】
- Hello, Peter. What do you do?____
A. I am fine.
B. I am not sick.
C. I am a student from Bonn University.
D. I came from Bonn University.
【单选题】
-Excuse me; can I have a seat here?___
A. Be hurry.
B. Come on.
C. Yes, please.
D. Do you mind?
【单选题】
- Shall we sit up here on the grass or down there near the water?___
A. I'd rather stay here if you don't mind.
B. Sorry, I don't like neither.
C. Certainly, why not?
D. Yes, we like these two places.
【单选题】
- What do you do on Sunday?___
A. I 'm a teacher.
B. I play football.
C. You are a student.
D. They clean rooms.
【单选题】
- Our class won the girls' relay race in our school's sports meeting.___
A. That's right.
B. Thanks a lot.
C. Congratulations!
D. It's a pleasure.