QuestionQ21

Python Basics

What is displayed when the following commands are entered in Python interactive mode?

Question Image

  • A 15
  • B NameError: name 'c' is not defined
  • C ac
  • D TypeError: cannot concatenate 'str' and 'int' objects
Explanation

Python does not allow the + operator to concatenate an integer with a string. The expression a + " " + "c" therefore raises a TypeError before any output is printed.

Community Discussion

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