python 刷题 time11.11

一个段代码定义如下,下列调用结果正确的是?

def bar(multiple):
def foo(n):
return multiple ** n
return foo
正确答案: A 你的答案: A (正确)
bar(2)(3) == 8
bar(2)(3) == 6
bar(3)(2) == 8
bar(3)(2) == 6

解析
# -*- coding: utf-8 -*-


def bar(multiple):
    def foo(n):
        return multiple ** n
    return foo


print(bar(2)(3) == 8)

# result
True

What gets printed?()

print r"\nwoow"
正确答案: C 你的答案: C (正确)
new line then the string: woow
the text exactly like this: r"\nwoow"
the text like exactly like this: \nwoow
the letter r and then newline then the text: woow
the letter r then the text like this: nwoow

解析
>print(r"\nwoow")
\nwoow

有如下类定义,下列描述错误的是?

class A(object):
pass

class B(A):
pass

b = B()
正确答案: D 你的答案: D (正确)
isinstance(b, A) == True
isinstance(b, object) == True
issubclass(B, A) == True
issubclass(b, B) == True

解析
  • isinstance() 函数来判断一个对象是否是一个已知的类型,类似 type()。
  • isinstance() 与 type() 区别:
    • type() 不会认为子类是一种父类类型,不考虑继承关系。
    • isinstance() 会认为子类是一种父类类型,考虑继承关系。
  • 参数
    • object – 实例对象。
    • classinfo – 可以是直接或间接类名、基本类型或者由它们组成的
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值