| 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 for the following piece of code? >>> a={1,2,3} >>> b=a >>> b.remove(3) >>> a

Correct Answer is : {1,2}

2. What is the output of the following piece of code? >>> a={1,2,3} >>> b=a.copy() >>> b.add(4) >>> a

Correct Answer is : {1,2,3}

3. What is the output of the following code? >>> a={1,2,3} >>> b=a.add(4) >>> b

Correct Answer is : Nothing is printed

4. What is the output of the following code? >>> a={1,2,3} >>> b=frozenset([3,4,5]) >>> a-b

Correct Answer is : {1,2}

5. What is the output of the following piece of code? >>> a={5,6,7} >>> sum(a,5)

Correct Answer is : 23

6. What is the output of the following code? >>> a={1,2,3} >>> {x*2 for x in a|{4,5}}

Correct Answer is : {8, 2, 10, 4, 6}

7. What is the output of the following piece of code? >>> a={5,6,7,8} >>> b={7,8,9,10} >>> len(a+b)

Correct Answer is : Error, unsupported operand ‘+’ for sets

8. What is the output of the following piece of code? a={1,2,3} b={1,2,3} c=a.issubset(b) print(c)

Correct Answer is : TRUE

9. Is the following piece of code valid? a={1,2,3} b={1,2,3,4} c=a.issuperset(b) print(c)

Correct Answer is : FALSE

10. What is the output of the code shown? s=set() type(s)

Correct Answer is :

11. The line of code shown below results in an error. State whether this statement is true or false. s={2, 3, 4, [5, 6]}

Correct Answer is : TRUE

12. Set makes use of __________ Dictionary makes use of ____________

Correct Answer is : keys, key values

13. Which of the following lines of code will result in an error?

Correct Answer is : s={san}

14. What is the output of the code shown below? s={2, 5, 6, 6, 7} s

Correct Answer is : {2, 5, 6, 7}

15. Input order is preserved in sets. State whether this statement is true or false.

Correct Answer is : FALSE

16. Write a list comprehension for number and its cube for: l=[1, 2, 3, 4, 5, 6, 7, 8, 9]

Correct Answer is : [x**3 for x in l]

17. What is the output of the code shown below? s={1, 2, 3} s.update(4) s

Correct Answer is : Error

18. Which of the following functions cannot be used on heterogeneous sets?

Correct Answer is : sum

19. What is the output of the code shown below? s={4>3, 0, 3-3} all(s) any(s)

Correct Answer is : FALSE

20. Which of the following functions will return the symmetric difference between two sets, x and y?

Correct Answer is : x & y