一. 单选题
- (单选题)下列数据类型中,Python不支持的是_______。
A. int
B. float
C. char
D. list - (单选题)Python语句"f1=lambda x:x*2; f2=lambda x:x**2; print(f1(f2(2)))"的程序运行结果是________
A. 2
B. 4
C. 6
D. 8
从里到外依次执行:f2(2):2**2=4,返回值是4
f1(f1(2))=f1(4):4*2=8,返回8
- (单选题)Python中,若def f1(p,**p2):print(type(p2)),则f1(1,a=2)的程序运行结果是_______。
A. <class ‘int’>
B. <class ‘type’>
C. <class ‘dict’>
D. <class ‘list’> - (单选题)下列哪些是可变对象?
A. int
B. str
C. list
D. float - (单选题)下列选项中,与s[0:-1]表示的含义相同的是______。
A. s[-1]
B. s[:]
C. s[:len(s)-1]
D. s[0:len(s)]]
- (单选题)Python程序中对于表达式123+‘XYZ’,解释器将抛出______错误信息。
A. NameError
B. FileNotFoundError
C. SyntaxError
D. TypeError
TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’
- (单选题)以下关于字符串的描述错误的是()
A. 字符串s的首字符是s[0]
B. 在字符串中,同一个字母的大小是等价的
C. 字符串中的字符都是以某种二进制编码的方式进行存储和处理的
D. 字符串也能进行关系比较操作 - (单选题)以下关于异常处理try语句块的说法,不正确的是_______。
A. finally语句中的代码始终要保证被执行
B. 一个try块后接一个或多个except块
C. 一个try块后接一个或多个finally块
D. try块必须与except或finally块一起使用 - (单选题)下列选项中,对于函数定义错误的是_______。
A. def myfunc(a,b)
B. def myfunc(a,*b)
C. def myfunc(*a,b)
D. def myfunc(a,b=2)
*a必须放在最后
- (单选题)
下列表达式中,能用于判断字符串s1是否属于字符串s(即s1是否s的子串)的是( )。
①s1 in s;②s.index(s1)>0; ③s.find(s1)>0;④s.rfind(s1)>0;⑤s.rindex(s1)>0
A. ①②
B. ①②③
C. ①②③④
D. ①②③④⑤
二. 填空题 - (填空题)Python表达式10+5//3-True+False的值为___ 10 _____。
10+1-1+0=10
-
(填空题)表达式 chr(ord(‘a’)-32) 的值为____A_______。
-
(填空题)数学表达式
的Python表达式为:__math.sin(15math.pi/180)+(math.pow(math.e,x)-5x)/math.sqrt(xx+1)-math.log(3x);____。
math.sin(15math.pi/180)+(math.pow(math.e,x)-5x)/math.sqrt(xx+1)-math.log(3x);
from math import *
sin(pi/12) + (ex -5x) / sqrt(xx + 1) - log(3x);
math.sin(15math.pi/180)+(math.exp(x)-5*×)/math.sqrt(x2+1)-math.log(3x);
from math import *
sin(radians(15))+(pow(e,x)-5x)/(sqrt(x2+1))-log(3*x,e);
math.sin(math.pi/12)+((math.ex-5x)/math.sqrt(x**2+1))- math.log(math.e,3x);
math.sin(15math.pi/180)+(math.exp(x)-5x)/math.sqrt(x2+1)-math.log(3x);
math.sin(15/180math.pi)+(math.exp(x)-5*x)/math.sqrt(x2+1)-math.log(math.e,3x);
math.sin(math.pi15/180) + ((math.exp(x) - 5x)/math.sqrt(x**2 + 1)) - math.log(3x);
math.sin(math.pi15/180) + (math.exp(x) - 5x)/math.sqrt(x**2 + 1) - math.log(3x);
sin(15math.pi/180)+(math.pow(math.e,x)-5x)/math.sqrt(xx+1)-math.log(3*x);
- (填空题)在直角坐标系中,x,y是坐标系中任意点的位置,用x和y表示第一象限或第二象限的Python表达式为____x>0______。
x>0 and y>0 or x<0 and y>0;
x>0 and y>0 or x<0 and y>0;
(x>0 and y>0) or (x<0 and y>0);
x!=0 and y>0;
x!=0 and y>0;
y>0 and x!=0;
(x<0 and y>0) or (x>0 and y>0)
-
(填空题)已知 x = [5, 6, 7],那么执行语句 x[:3] = [8]之后,x的值为______ [8] _____ ;此时再执行语句 x[3:] = [9]之后,x的值为___ [8,9] ___。
-
(填空题)在python中,使用内置函数___ locals() ___ 和____globals()___,可以查看并输出局部变量和全局变量列表。
-
(填空题)已知 arr = [[3,4], [8,9]],则表达式 [col for row in arr for col in row] 的值为___[3, 4, 8, 9]____。
-
(填空题)表达式 {1, 2, 3} & {2, 3, 4} 的值为____{2,3} ____ ;表达式 {1, 2, 3} - {3, 4, 5} 的值为__ {1,2} ____。