QuestionQ111

Strings

What behavior should be expected from this code?

Question Image

  • A it outputs 3
  • B it outputs 'None'
  • C it outputs 0
  • D it raises an exception
Explanation

Floor division of 1 by 3 evaluates to 0, and str(0) is '0'. The loop leaves dummy as '0', and dummy[-1] retrieves its last character, which is printed as 0.

Community Discussion

No comments yet. Be the first to start the discussion!