2022年Python笔试选择题及答案(秋招)

2022年Python笔试选择题及答案(秋招)

单选题
1.以下关于 Python 的描述错误的是?

A、Python 的语法类似 PHP
B、Python 可用于 Web 开发
C、Python 是跨平台的
D、Python 可用于数据抓取(爬虫)
正确答案:C

单选题
2.Python 中,以下哪个函数是用于输出内容到终端的?

A、echo
B、output
C、print
D、console.log
正确答案:A

单选题
3.以下哪个符号是用作 Python 的注释?

A、*
B、(comment)
C、//
D、#

正确答案:D
建议收藏起来方便下次观看

单选题
4.以下哪个标记是用作 Python 的多行注释?

A、‘’’
B、///
C、###
D、(comment)
正确答案:A

单选题
5.Python 中,以下哪个变量的赋值是正确的?

A、var a = 2
B、int a = 2
C、a = 2
D、variable a = 2
正确答案:C

单选题
6.变量 a 的值为字符串类型的 "2",如何将它转换为整型?
A、castToInt(a)
B、int(a)
C、integer(a)
D、castToInteger(a)
正确答案:B

单选题
7.Python 中,以下哪个赋值操作符是错误的?

A、+=
B、-=
C、*=
D、X=
正确答案:D

单选题
8.代码 L = [1, 23, "nowcoder", 1] 输出的数据类型是?

A、List
B、Dictionary
C、Tuple
D、Array
正确答案:D

单选题
9.下面哪一个不是 Python 的数据类型?

A、列表(List)
B、字典(Dictionary)
C、元组(Tuples)
D、类(Class)
正确答案:A

单选题
10.代码 a = [ 1,2,3,4,5 ],以下输出结果正确的是?

A、print(a[:]) => [1,2,3,4]
B、print(a[0:]) => [2,3,4,5]
C、print(a[:100]) => [1,2,3,4,5]
D、print(a[-1:]) => [1,2]
正确答案:C
建议收藏起来方便下次观看

单选题
11.以下哪个代码是将字符串转换为浮点数?

A、int(x [,base])
B、long(x [,base])
C、float(x)
D、str(x)
正确答案:C

多选题
12.以下哪个 if 语句是正确的?

A、if a >= 22:
B、if (a >= 22):
C、if (a => 22)
D、if a >= 22
正确答案:AB

单选题
13.以下哪个关键字是用于给 if 语句添加其他条件语句的?

A、else if
B、elseif
C、elif
D、其他都不对
正确答案:C

单选题
14.以下代码中哪个是定义函数的语句是正确的?

A、def someFunction():
B、function someFunction()
C、def someFunction()
D、function someFunction():
正确答案:A

单选题
15.以下代码中哪个是正确的 for 循环语句是?

A、for(a = 0; a < 3; a++)
B、for a in range(3)
C、for a loop 3:
D、for a in range(1,3):
正确答案:D

单选题
16.以下python代码中哪个是正确的 while 循环语句是?

A、while loop a < 10
B、while a <10:
C、while(a < 10)
D、while loop a < 10:
正确答案:B

单选题
17.假设你有一个变量 "example",如何判断它的类型?

A、getType(example)
B、Type(example)
C、type(example)
D、example.type:
正确答案:C

单选题
18.将字符串 "example" 中的字母 a 替换为字母 b,以下代码正确的是?

A、example.swap(‘b’, ‘a’)
B、example.replace(‘a’,‘b’)
C、example.match(‘b’,‘a’)
D、example.replace(‘b’,‘a’)
正确答案:B

单选题
19.Python 中,以下哪个代码是正确的列表?

A、sampleList = {1,2,3,4,5}
B、sampleList = (1,2,3,4,5)
C、sampleList = /1,2,3,4,5/
D、sampleList = [1,2,3,4,5]
正确答案:D

单选题
20.Python 中,以下哪个代码是正确的元组?

A、sampleTuple = (1,2,3,4,5)
B、sampleTuple = {1,2,3,4,5}
C、sampleTuple = [1,2,3,4,5]
D、sampleList = /1,2,3,4,5/
正确答案:A

单选题
21.Python 中,以下哪个代码是正确的字典?

A、myExample = {‘someItem’=>2, ‘otherItem’=>20}
B、myExample = {‘someItem’: 2, ‘otherItem’: 20}
C、myExample = (‘someItem’=>2, ‘otherItem’=>20)
D、myExample = (‘someItem’: 2, ‘otherItem’: 20)
正确答案:B

单选题
22.代码 print(type([1,2])) 输出结果为:

A、<class ‘tuple’>
B、<class ‘int’>
C、<class ‘set’>
D、<class ‘list’>
E、<class ‘complex’>
正确答案:D

单选题
23.下面代码输出结果为?

def f(): pass
print(type(f()))

A、<class ‘function’>
B、<class ‘tuple’>
C、<class ‘NoneType’>
D、<class ‘str’>
E、<class ‘type’>
正确答案:C

单选题
24.下面代码输出结果为?

a = [1,2,3,None,(),[],]
print(len(a))

A、syntax error
B、4
C、5
D、6
E、7
正确答案:D

单选题
25.Python 中,如何输出列表中的第二个元素?
A、print(example[2])
B、echo(example[2])
C、print(example[1])
D、print(example(2))
正确答案:C

单选题
26.print('%.2f' % 123.444) 输出结果为?

A、123.44
B、12
C、123.444
D、44
正确答案:A

单选题
27.代码 def a(b, c, d): pass 含义是?
A、定义一个列表,并初始化它。
B、定义一个函数,但什么都不做。
C、定义一个函数,并传递参数。
D、定义一个空的类。
27.
代码 def a(b, c, d): pass 含义是?

单选题
28.以下哪个关键字是与 try 语句一起使用来处理异常的?
A、catch
B、exception
C、catch(a)
D、except
正确答案:D

单选题
29.以下哪个代码是正确的读取一个文件?
A、f = open(“test.txt”, “read”)
B、f = open(“r”,“test.txt”)
C、f = open(“test.txt”, “r”)
D、f = open(“read”,“test.txt”)
正确答案:C

单选题
30.以下哪个代码是正确的打开文件并准备写入?

A、f = open(“test.txt”,“w”)
B、f = open(“test.txt”,“write”)
C、f = open(“write”,“test.txt”)
D、f = open(“w”,“test.txt”)
正确答案:A
请添加图片描述

  • 7
    点赞
  • 46
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编程ID

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值