nerdexam
Python_Institute

PCEP-30-02 · Question #157

What is the expected behavior of the following program? ``python print("Hello!") ``

The correct answer is A. The program will output Hello! to the screen. Option A is correct because Python's print() function outputs its argument to standard output (the screen) without the surrounding quotation marks - the quotes in the source code are string delimiters, not part of the value itself. Why the distractors are wrong: B is wrong…

Question

What is the expected behavior of the following program?
print("Hello!")

Options

  • AThe program will output Hello! to the screen
  • BThe program will generate an error on the screen
  • CThe program will output "Hello!" to the screen
  • DThe program will output "Hello!" to the screen

How the community answered

(23 responses)
  • A
    78% (18)
  • B
    4% (1)
  • C
    4% (1)
  • D
    13% (3)

Explanation

Option A is correct because Python's print() function outputs its argument to standard output (the screen) without the surrounding quotation marks - the quotes in the source code are string delimiters, not part of the value itself.

Why the distractors are wrong:

  • B is wrong because print("Hello!") is valid Python syntax with no errors - it will execute successfully every time.
  • C and D are wrong because they show "Hello!" with quotation marks in the output. Python's print() strips the string delimiters; only the contents between the quotes are printed.

Memory tip: Think of quotation marks as a container, not the contents. print() opens the container and displays only what's inside - so "Hello!" on screen becomes Hello!, not "Hello!".

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice