浙江大学python程序设计(陈春晖、翁恺、季江民)习题答案
第二章
一、单选题
1.下列数据类型中,Python不支持的是( A
)
A.char B.int C.float D.list
2.Python语句print(type(1J))的输出结果是( A
)
A.<class 'complex'> B.<class 'int'>
C.<class 'float'> D.<class 'dict'>
3.Python语句print(type(1 / 2))的输出结果是( C
)
A.<class 'int'> B.<class 'number'>
C.<class 'float'> D.<class 'double'>
4.Python语句print(type(1 // 2))的输出结果是( A
)
A.<class 'int'> B.<class 'number'>
C.<class 'float'> D.<class 'double'>
5.Python语句a=121 + 1.21;print(type(a))的输出结果是( B
)
A.<class 'int'> B.<class 'float'>
C.<class 'double'> D.<class 'long'>
6.Python语句print(0xA + 0xB)的输出结果是( D
)
A.0xA + 0xB B.A + B C.0xA0xB D.21
7.Python语句x=‘car’;y=2;print(x + y)的输出结果是( A
)
A.语法错 B.2 C.car2 D.carcar
8.Python表达式 sqrt(4) * sqrt(9) 的值为( D
)
A.36.0 B.1296.0 C.13.0 D.6.0
9.关于Python中的复数,下列说法错误的是( C
)
A.表示复数的语法是real+image j B.实部和虚部都是浮点数
C.虚部必须加后缀j,且必须是小写 D.方法real返回复数的实部
10.Python语句print(chr(65))的运行结果是( D
)
A.65 B.6 C.5 D.A
11.关于Python字符串,下列说法错误的是( B
)
A.字符即长度为1的字符串
B.字符串以\0标志字符串结束
C.既可以用单引号,又可以用双引号创建字符串
D.在三引号字符串中可以包含换行、回车等特殊字符
二、填空题
1.Python表达式10+5//3-True+False的值为(10
)
2.Python表达式3**2**3
的值为(6561
)
3.Python表达式17.0 / 3**2的值为(1.89
)
4.Python表达式 0 and 1 or not 2 < True 的值为(True
)
5.Python语句 print(pow(-3,2),round(18.67,1),round(18.67,-1))的输出结果是(9 ,18.7 , 20.0
)
6.Python语句 print(round(123.84,0),round(123.84,-2),floor(15.5))的输出结果是(124.0 , 100.0 , 15
)
7.Python语句print(int(“20”,16),int(“101”,2))的输出结果是(32 , 5
)
8.Python语句print(hex(16),bin(10))的输出结果是(0x10 ,0b1010
)
9.Python语句print(abs(-3.2),abs(1-2j))的输出结果是(3.2, 2.24
)
10.数学表达式:
的python表达式为math.sin(0.61087) + ((e**2) -15 * x) / math.sqrt((x**4) + 1) - math.log10(7 * x)
11.Python语句 x=True;y=False;z=False;print(x or y and z)的程序运行结果是(True
)
12.Python语句 x=0;y=True;print(x>=y and ‘A’<‘B’)的程序运行结果是(False
)
13.已知a=3;b=5;c=6;d=True,则表达式not d or a>=0 and a+c>b+3的值是(True
)
14.Python表达式16-25>78/2 or “XYZ”!=“xyz” and not (10-6>18/2)的值是(True
)
15.Python语句print(“hello”‘world’)的结果是(helloworld
)