Question:

Identify the invalid Python statement out of the following options:

Show Hint

In Python function calls,
positional arguments must always come before keyword arguments.
Mixing the order causes a syntax error.
  • print("A", 10, end="*")
  • print("A", sep="*", 10)
  • print("A", 10, sep="*")
  • print("A"*10)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

The print() function in Python prints objects to the standard output.
Its syntax allows you to pass multiple positional arguments first, followed by keyword arguments.
Common keyword arguments include sep for separator and end for line ending.
Option (A) is valid: it prints `"A"` and `10` with end="*" to modify the line ending.
Option (C) is valid: it prints `"A"` and `10` with sep="*" between them.
Option (D) is valid: `"A"*10` evaluates to `"AAAAAAAAAA"`, which is fine.
Option (B) is invalid because it mixes positional arguments after a keyword argument.
In Python, positional arguments must come first — any positional argument after a keyword argument raises a SyntaxError.
Therefore, the invalid statement is option (B).
Was this answer helpful?
0
0

Top Questions on Programming in Python

View More Questions

Questions Asked in CBSE CLASS XII exam

View More Questions