Python Interview Question:

Python Interview Question:

Beginners

  1. See the statement and give the answer.

>>> a = 10

>>> b = 10

>>> id(a) == id(b)

?

Answer: True

  1. Operator to denote power.

Answer: **

  1. According to Python 3

3*10/11 == 10/11*3     ?

True or False

Answer: True

  1. 3>5 and 5< M == 5< M and 3 > 5 ?

True and False

Answer: False

  1. See the series of command and give the answer.

>>> a = 10

>>> b = a

>>> a

10

>>> b

10

>>> del a

>>> b

?

Answer: 10

  1. >>> if -1:

…     print (“YES”)

Answer:  Yes

  1. >>> if 0:

…     print (“YES”)

Answer:

  1. Taking Python 3.7 into account.

range(10,67)[8]

?

Answer: 18

  1. See the series of commands and give the answer
    >>> sys.getsizeof(range(10))

48

>>> sys.getsizeof(range(20))

48

>>> sys.getsizeof(range(1000000))

48

>>>

Answer: 48

  1. See the series of command and give the answer

>>> name = “Hello Jarvis”

>>> name.upper()

‘HELLO JARVIS’

>>> name

?

Answer: Hello Jarvis

  1. >>> name = “Hello Jarvis”

name[-9:9]

?

Answer: ‘lo Jar’

  1. >>> name = “Hello Jarvis”

>>> name[-3:-9]

?

Answer:  ‘’

  1. >>> name = “##$$Hello$$##”

>>> name.strip(“#$”)

?

Answer: ‘Hello’

  1. Write the code snippet

ip = “192.168.0.1”

<code>

Output [‘192.168.0’, ‘1’]

Answer: ip.rsplit(“.”,1)

  1. >>> A = 1,2,3,4

>>> type(A)

?

Answer:  <class ‘tuple’>

  1. Find the result

>>> tup1 = (1,2,3,4,”b”)

>>> tup2 = tup1[:]

>>> tup1 is tup2   ?

Answer: True

  1. >>> tup1 = (1,2,3,4)

>>> del tup1[2]

What would be the answer?

Answer: Traceback (most recent call last):

File “<stdin>”, line 1, in <module>

TypeError: ‘tuple’ object doesn’t support item deletion

  1. >>> tup1 = (1,2,3,”a”, “b”)

>>> max(tup1)

What would be the answer ?

Answer: Traceback (most recent call last):