πŸ“Š Problem Solving and Python Programming
Q. , 11))
  • (A) 2
  • (B) 0
  • (C) 1
  • (D) error
πŸ’¬ Discuss
βœ… Correct Answer: (B) 0

Explanation: counts the number of times the substring ‘xyy’ is present in the given string, starting from position 2 and ending at position 11.

πŸ“Š Problem Solving and Python Programming
Q. } and {1}".format('foo', 'bin'))
  • (A) hello foo and bin
  • (B) hello {0} and {1} foo bin
  • (C) error
  • (D) hello 0 and 1
πŸ’¬ Discuss
βœ… Correct Answer: (A) hello foo and bin

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

πŸ“Š Problem Solving and Python Programming
Q. } and {0}".format('bin', 'foo'))
  • (A) hello foo and bin
  • (B) hello bin and foo
  • (C) error
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) hello foo and bin

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

πŸ“Š Problem Solving and Python Programming
Q. } and {name2}".format( 'foo', 'bin'))
  • (A) hello foo and bin
  • (B) hello {name1} and {name2}
  • (C) error
  • (D) hello and
πŸ’¬ Discuss
βœ… Correct Answer: (C) error

Explanation: the arguments passed to the function format aren’t keyword arguments.

πŸ“Š Problem Solving and Python Programming
Q. !r} and {0!s}".format('fo o', 'bin'))
  • (A) hello foo and foo
  • (B) hello ‘foo’ and foo
  • (C) hello foo and ‘bin’
  • (D) error
πŸ’¬ Discuss
βœ… Correct Answer: (B) hello ‘foo’ and foo

Explanation: !r causes the characters ‘ or ” to be printed as well.

πŸ“Š Problem Solving and Python Programming
Q. } and {1}".format(('foo', 'bin')))
  • (A) hello foo and bin
  • (B) hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
  • (C) error
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (C) error

Explanation: indexerror, the tuple index is out of range.

Jump to