Which of the following is the correct way to print "Hello, world!" in Python?
Correct answer
B. print("Hello, world!")
16 views
B. print("Hello, world!")
16 views
print("Hello, world!") is correct. In Python 3 print is a built-in function, so parentheses are required.
The other options come from other languages: System.out.println is Java, echo is PHP and shell, and cout << is C++.
For more solved questions like this one, see Computer Science MCQs on MCQsExam.com.
Not sure why the answer is B? Ask here and get an explanation.