Sail E0 Webinar

MCQs

Total Questions : 13 | Page 1 of 2 pages
Question 1. What is the output of "hello+1+2+3 ?
  1.    hello123
  2.    hello
  3.    Error
  4.    hello6
 Discuss Question
Answer: Option C. -> Error


Cannot concantenate str and int objects.


Question 2. What is the output of the following code ?example = "snow world"example[3] = 's'print example
  1.    snow
  2.    snow world
  3.    Error
  4.    snos world
 Discuss Question
Answer: Option C. -> Error


Strings cannot be modified.


Question 3. What is the output when following code is executed ?print r"\nhello"The output is
  1.    a new line and hello
  2.    \nhello
  3.    the letter r and then hello
  4.    Error
 Discuss Question
Answer: Option B. -> \nhello


When prefixed with the letter 'r' or 'R' a string literal becomes a raw string and the escape sequences such as \n are not converted.


Question 4. What is the output of the following?print('*', "abcdef".center(7), '*')
  1.    * abcdef *
  2.    * abcdef *
  3.    *abcdef *
  4.    * abcdef*
 Discuss Question
Answer: Option B. -> * abcdef *


Padding is done towards the left-hand-side first when the final string is of odd length. Extra spaces are present since we haven't overridden the value of sep.


Question 5. Suppose i is 5 and j is 4, i + j is same as
  1.    i.__add(j)
  2.    i.__add__(j)
  3.    i.__Add(j)
  4.    i.__ADD(j)
 Discuss Question
Answer: Option B. -> i.__add__(j)


Execute in shell to verify.


Question 6. What is the output of the following?print('ab'.isalpha())
  1.    True
  2.    False
  3.    None
  4.    Error
 Discuss Question
Answer: Option A. -> True


The string has only letters.


Question 7. What is the output of the following?print('The sum of {0} and {1} is {2}'.format(2, 10, 12))
  1.    The sum of 2 and 10 is 12
  2.    Error
  3.    The sum of 0 and 1 is 2
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> The sum of 2 and 10 is 12


The arguments passed to the function format can be integers also.


Question 8. What is the output of the following?print("xyyzxyzxzxyy".count('xyy', 2, 11))
  1.    2
  2.    0
  3.    1
  4.    Error
 Discuss Question
Answer: Option B. -> 0


Counts the number of times the sub-string 'xyy' is present in the given string, starting from position 2 and ending at position 11.


Question 9. What is the output of the following?print("Hello {1} and {0}".format('bin', 'foo'))
  1.    Hello foo and bin
  2.    Hello bin and foo
  3.    Error
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> Hello foo and bin


The numbers 0 and 1 represent the position at which the strings are present.


Question 10. What is the output of the following?print('1.1'.isnumeric())
  1.    True
  2.    False
  3.    None
  4.    Error
 Discuss Question
Answer: Option B. -> False


The character . is not a numeric character.


Latest Videos

Latest Test Papers