python作业2

一. 单选题

  1. (单选题)下列数据类型中,Python不支持的是_______。
    A. int
    B. float
    C. char
    D. list
  2. (单选题)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

  1. (单选题)Python中,若def f1(p,**p2):print(type(p2)),则f1(1,a=2)的程序运行结果是_______。
    A. <class ‘int’>
    B. <class ‘type’>
    C. <class ‘dict’>
    D. <class ‘list’>
  2. (单选题)下列哪些是可变对象?
    A. int
    B. str
    C. list
    D. float
  3. (单选题)下列选项中,与s[0:-1]表示的含义相同的是______。
    A. s[-1]
    B. s[:]
    C. s[:len(s)-1]
    D. s[0:len(s)]]

在这里插入图片描述

  1. (单选题)Python程序中对于表达式123+‘XYZ’,解释器将抛出______错误信息。
    A. NameError
    B. FileNotFoundError
    C. SyntaxError
    D. TypeError

TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’

  1. (单选题)以下关于字符串的描述错误的是()
    A. 字符串s的首字符是s[0]
    B. 在字符串中,同一个字母的大小是等价的
    C. 字符串中的字符都是以某种二进制编码的方式进行存储和处理的
    D. 字符串也能进行关系比较操作
  2. (单选题)以下关于异常处理try语句块的说法,不正确的是_______。
    A. finally语句中的代码始终要保证被执行
    B. 一个try块后接一个或多个except块
    C. 一个try块后接一个或多个finally块
    D. try块必须与except或finally块一起使用
  3. (单选题)下列选项中,对于函数定义错误的是_______。
    A. def myfunc(a,b)
    B. def myfunc(a,*b)
    C. def myfunc(*a,b)
    D. def myfunc(a,b=2)

*a必须放在最后

  1. (单选题)
    下列表达式中,能用于判断字符串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. ①②③④⑤
    二. 填空题
  2. (填空题)Python表达式10+5//3-True+False的值为___ 10 _____。

10+1-1+0=10

  1. (填空题)表达式 chr(ord(‘a’)-32) 的值为____A_______。

  2. (填空题)数学表达式在这里插入图片描述
    的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(15
math.pi/180)+(math.exp(x)-5*×)/math.sqrt(x
2+1)-math.log(3x);
from math import *
sin(radians(15))+(pow(e,x)-5
x)/(sqrt(x2+1))-log(3*x,e);
math.sin(math.pi/12)+((math.e
x-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/180
math.pi)+(math.exp(x)-5*x)/math.sqrt(x
2+1)-math.log(math.e,3x);
math.sin(math.pi
15/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(15
math.pi/180)+(math.pow(math.e,x)-5x)/math.sqrt(xx+1)-math.log(3*x);

  1. (填空题)在直角坐标系中,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)

  1. (填空题)已知 x = [5, 6, 7],那么执行语句 x[:3] = [8]之后,x的值为______ [8] _____ ;此时再执行语句 x[3:] = [9]之后,x的值为___ [8,9] ___。

  2. (填空题)在python中,使用内置函数___ locals() ___ 和____globals()___,可以查看并输出局部变量和全局变量列表。

  3. (填空题)已知 arr = [[3,4], [8,9]],则表达式 [col for row in arr for col in row] 的值为___[3, 4, 8, 9]____。

  4. (填空题)表达式 {1, 2, 3} & {2, 3, 4} 的值为____{2,3} ____ ;表达式 {1, 2, 3} - {3, 4, 5} 的值为__ {1,2} ____。

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值