2019年最新出炉python面试题(一)

2019年python面试题一

1.which of the following is invalid?
a)_a=1
b)__a=1
c)__str__=1
d)none of the mentioned
答案:(d)
2.which of the following is not a keyword?
a)eval
b)assert
c)nonlocal
d)pass
答案:a
3.which of the following is an invalid statement?
a)abc = 1,000,000
b)a b c = 1000 2000 3000
c)a,b,c = 1000,2000,3000
d)a_b_c = 1,000,000
答案:b
4.what is the output of this expression,3*1**3?
a)27
b)9
c)3
d)1
答案:c
5.which of the following is incorrect?
a)float('inf')
b)float('nan')
c)float('56'+'78')
d)float('12+34')
答案:d
6.what dose 3^4 evaluate to?
a)81
b)12
c)0.75
d)7
答案:d
7.Consider the expression given below.The value of X is:X=2+9*((3*12)-8)/10?
a)30.0
b)30.8
c)28.4
d)27.2
答案:d
8.what is the output of the following?
    i = 5
    while True:
        if i%0o11 == 0:
            break
        print(i)
        i += 1
a)5 6 7 8 9
b)5 6 7 8
c)5 6
d)error
答案:b
9.what is the output of the following?
    print("abcdefcdghcd".split("cd",2))
a)["ab","ef","ghcd"]
b)["ab","efcdghcd"]
c)["abcdef","ghcd"]
d)none of the mentioned
答案:a
10.what dose the following piece of code do?
    print(list(zip((1,2,3),("a"),('xxx','yyy'))))
    print(list(zip((2,4),('b','c'),('yy','xx'))))
a)[(1,2,3),('a'),('xxx','yyy')]
[(2,4),('b','c'),('yy','xx')]
b)[(1, 'a', 'xxx'),(2,'','yyy'),(3,'','')]
[(2,'b','yy'),(4,'c','xx')]
c)Syntax error
d)[(1, 'a', 'xxx')]
[(2, 'b', 'yy'), (4, 'c', 'xx')]
答案:d
11. What is the output of the code shown?
    s = ['pune','mumbai','delhi']
    [(w.upper(), len(w)) for w in s]
a)error
b)['PUNE', 4,'MUMBAI', 6,'DELHI', 5]
c)[PUNE, 4,MUMBAI, 6,DELHI, 5]
d)[('PUNE', 4), ('MUMBAI', 6), ('DELHI', 5)]
答案:d
12.which of the following lines of code will result in an error?
a)s = {abs}
b)s = {4,'abc',(1,2)}
c)s = {2,2.2,3,'xyz'}
d)s = {san}
答案:d
13.Suppose d={'john':40,'peter',45},to delete the entry for "john" what command do?
a)d.delete('john':40)
b)d.delete('john')
c)del d['john']
d)del d['john':40]
答案:c
14.what is the output of the code shown below?
    import re
    s='abc123 xyz666 lmn-11 def77'
    re.sub(r'\b([a-z]+)(\d+)',r'\2\1',s)
a)'123abc 666xyz lmn-11 def77'
b)'77def lmn-11 666xyz 123abc'
c)'abc123','xyz666','lmn-11','def77'
d)'abc123 xyz666 lmn-11 def77'
答案:a
15.what is the output of the following piece of code?
a)13
b)7
c)infinite loop
d)17
答案:d

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值