| Snaprecruit.com

| Snaprecruit.com

Interview question based on skill :

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. What is the output of the following piece of code when executed in Python shell? >>> a=("Check")*3 >>> a

Correct Answer is : (‘CheckCheckCheck’)

2. What is the output of the following code? >>> a=(1,2,3,4) >>> del(a[2])

Correct Answer is : Error as tuple is immutable

3. What is the output of the following code? >>> a=(2,3,4) >>> sum(a,3)

Correct Answer is : 12

4. Is the following piece of code valid? >>> a=(1,2,3,4) >>> del a

Correct Answer is : Yes, the entire tuple is deleted

5. What type of data is: a=[(1,1),(2,4),(3,9)]?

Correct Answer is : List of tuples

6. What is the output of the following piece of code? >>> a=(0,1,2,3,4) >>> b=slice(0,2) >>> a[b]

Correct Answer is : (0,1)

7. Is the following piece of code valid? >>> a=(1,2,3) >>> b=('A','B','C') >>> c=zip(a,b)

Correct Answer is : Yes, c will be ((1,2,3),(‘A’,’B’,’C’))

8. Is the following piece of code valid? >>> a,b,c=1,2,3 >>> a,b,c

Correct Answer is : Yes, (1,2,3) is printed

9. What is the output of the following piece of code? a = ('check',) n = 2 for i in range(int(n)): a = (a,) print(a)

Correct Answer is : ((‘check’,),)

10. Is the following line of code valid? >>> a,b=1,2,3

Correct Answer is : No, too many values to unpack

11. What is the output of the following piece of code when executed in Python shell? >>> a=(1,2) >>> b=(3,4) >>> c=a+b >>> c

Correct Answer is : (1,2,3,4)

12. What is the output of the following code? >>> a,b=6,7 >>> a,b=b,a >>> a,b

Correct Answer is : (7,6)

13. What is the output of the following code? >>> import collections >>> a=collections.namedtuple('a',['i','j']) >>> obj=a(i=4,j=7) >>> obj

Correct Answer is : a(i=4, j=7)

14. Tuples can’t be made keys of a dictionary. True or False?

Correct Answer is : FALSE

15. Is the following piece of code valid? >>> a=2,3,4,5 >>> a

Correct Answer is : Yes, (2,3,4,5) is printed

16. What is the output of the following piece of code? >>> a=(2,3,1,5) >>> a.sort() >>> a

Correct Answer is : Error, tuple has no attribute sort

17. Is the following piece of code valid? >>> a=(1,2,3) >>> b=a.update(4,)

Correct Answer is : No because tuples are immutable

18. What is the output of the following piece of code? >>> a=[(2,4),(1,2),(3,9)] >>> a.sort() >>> a

Correct Answer is : Error, tuple has no sort attribute

19. What is the output shape of the code shown? import turtle t=turtle.Pen() for i in range(0,4): t.forward(100) t.left(120)

Correct Answer is : triangle

20. The number of lines drawn in each case, assuming that the turtle module has been imported: Case 1: for i in range(0,10): turtle.forward(100) turtle.left(90) Case 2: for i in range(1,10): turtle.forward(100) turtle.left(90)

Correct Answer is : 45574