Python interview questions part 53

Python interview questions part 53

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? print('abc'.encode())

Correct Answer is : b’abc’

2. What is the default value of encoding in encode()?

Correct Answer is : utf-8

3. What is the output of the following? print("xyyzxyzxzxyy".endswith("xyy"))

Correct Answer is : TRUE

4. What is the output of the following? print("xyyzxyzxzxyy".endswith("xyy", 0, 2))

Correct Answer is : FALSE

5. What is the output of the following? print("ab\tcd\tef".expandtabs())

Correct Answer is : ab cd ef

6. What is the output of the following? print("ab\tcd\tef".expandtabs(4))

Correct Answer is : ab cd ef

7. What is the output of the following? print("ab\tcd\tef".expandtabs('+'))

Correct Answer is : none of the mentioned

8. What is the output of the following? print("abcdef".find("cd") == "cd" in "abcdef")

Correct Answer is : FALSE

9. What is the output of the following? print("abcdef".find("cd"))

Correct Answer is : 2

10. What is the output of the following? print("ccdcddcd".find("c"))

Correct Answer is : 0

11. What is the output of the following? print("Hello {0} and {1}".format('foo', 'bin'))

Correct Answer is : Hello foo and bin

12. What is the output of the following? print("Hello {1} and {0}".format('bin', 'foo'))

Correct Answer is : Hello foo and bin

13. What is the output of the following? print("Hello {} and {}".format('foo', 'bin'))

Correct Answer is : Hello foo and bin

14. What is the output of the following? print("Hello {name1} and {name2}".format('foo', 'bin'))

Correct Answer is : Error

15. What is the output of the following? print("Hello {name1} and {name2}".format(name1='foo', name2='bin'))

Correct Answer is : Hello foo and bin

16. What is the output of the following? print("Hello {0!r} and {0!s}".format('foo', 'bin'))

Correct Answer is : Hello ‘foo’ and foo

17. What is the output of the following? print("Hello {0} and {1}".format(('foo', 'bin')))

Correct Answer is : Error

18. What is the output of the following? print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))

Correct Answer is : Hello foo and bin

19. What is the output of the following? print('The sum of {0} and {1} is {2}'.format(2, 10, 12))

Correct Answer is : The sum of 2 and 10 is 12

20. What is the output of the following? print('The sum of {0:b} and {1:x} is {2:o}'.format(2, 10, 12))

Correct Answer is : The sum of 10 and a is 14

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon