LearnFrenzy
Sign in Take a free test

Python Basics and Syntax · Predict the Output · Question 2

Separators and adjacent string literals Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 2 Back to Exercise

What is the output of the following Python program?

main.py
print(1, 2, 3)
print(1, 2, 3, sep="")
print("ab" "cd", "ef")
  • A 1 2 3 1 2 3 ab cd ef
  • B 1 2 3 123 ab cd ef
  • C 1 2 3 123 abcd ef Correct
  • D 123 123 abcdef
Correct Answer: Option C

Two string literals written next to each other are joined at compile time ("abcd"), so print receives two values: "abcd" and "ef".

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links