Bird
0
0

What is the output of the following code?

medium📝 Predict Output Q5 of 15
Python - Input and Output
What is the output of the following code?
print('X', 'Y', sep='-', end='***')
print('Z')
AX-Y ***Z
BX-Y***Z
CX Y***Z
DX-Y*** Z
Step-by-Step Solution
Solution:
  1. Step 1: Analyze sep parameter

    The sep='-' inserts a dash between 'X' and 'Y'.
  2. Step 2: Analyze end parameter

    end='***' appends three asterisks instead of a newline after printing 'X-Y'.
  3. Step 3: Second print()

    Prints 'Z' immediately after the asterisks without newline.
  4. Final Answer:

    X-Y***Z -> Option B
  5. Quick Check:

    Check separator and end string placement [OK]
Quick Trick: end replaces newline; sep inserts between values [OK]
Common Mistakes:
MISTAKES
  • Assuming end adds newline
  • Ignoring sep effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes