| 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. Given a string example=”hello” what is the output of example.count(‘l’)

Correct Answer is : 2

2. What is the output of the following code ? >>>example = "helle">>>example.find("e")

Correct Answer is : 1

3. What is the output of the following code ? >>>example = "helle">>>example.rfind("e")

Correct Answer is : 4

4. What is the output of the following code ? >>>example="helloworld">>>example[::-1].startswith("d")

Correct Answer is : TRUE

5. To concatenate two strings to a third what statements are applicable ?

Correct Answer is : s3 = s1.__add__(s2)

6. What is the output when following statement is executed ? >>>chr(ord('A'))

Correct Answer is : A

7. What is the output when following statement is executed ? >>>print(chr(ord('b')+1))

Correct Answer is : c

8. Which of the following statement prints hello\example\test.txt ?

Correct Answer is : print(“hello\\example\\test.txt”)

9. Suppose s is “\t\tWorld\n”, what is s.strip() ?

Correct Answer is : World

10. The format function, when applied on a string returns :

Correct Answer is : str

11. What is the output of “hello”+1+2+3 ?

Correct Answer is : Error

12. What is the output when following code is executed ? >>>print("D", end = ' ')>>>print("C", end = ' ')>>>print("B", end = ' ')>>>print("A", end = ' ')

Correct Answer is : D, C, B, A will be displayed on four lines

13. What is the output when following statement is executed ?(python 3.xx) >>>print(format("Welcome", "10s"), end = '#')>>>print(format(111, "4d"), end = '#')>>>print(format(924.656, "3.2f"))

Correct Answer is : Welcome   # 111#924.66

14. What will be displayed by print(ord(‘b’) – ord(‘a’)) ?

Correct Answer is : 1

15. Say s=”hello” what will be the return value of type(s) ?

Correct Answer is : str

16. What is “Hello”.replace(“l”, “e”)

Correct Answer is : Heeeo

17. To return the length of string s what command do we execute ?

Correct Answer is : s.__len__()

18. If a class defines the __str__(self) method, for an object obj for the class, you can use which command to invoke the __str__ method.

Correct Answer is : All of the mentioned

19. To check whether string s1 contains another string s2, use

Correct Answer is : s1.__contains__(s2)

20. Suppose i is 5 and j is 4, i + j is same as

Correct Answer is : i.__add__(j)