debra450
debra450 Jan 16, 2026 โ€ข 0 views

Multiple Choice Questions on Python Print Statements

Hey everyone! ๐Ÿ‘‹ Let's test your Python print statement skills! This quick guide and quiz will help you master the basics. Good luck! ๐Ÿ€
๐Ÿ’ป Computer Science & Technology

1 Answers

โœ… Best Answer

๐Ÿ“š Quick Study Guide

  • โœจ The `print()` function in Python displays output to the console.
  • ๐Ÿ”— You can print strings, numbers, variables, and even the results of expressions.
  • ๐Ÿงฎ Multiple items can be printed in a single `print()` statement by separating them with commas.
  • โœ‚๏ธ The `sep` argument in `print()` specifies the separator between the items (default is a space).
  • end The `end` argument specifies what to print at the end of the `print()` statement (default is a newline character `\n`).
  • ๐Ÿ“œ f-strings (formatted string literals) provide a concise way to embed expressions inside string literals for formatting.
  • ๐Ÿ’ก You can control the formatting of numbers using format specifiers within f-strings (e.g., `:.2f` for two decimal places).

Practice Quiz

  1. Which of the following is the correct way to print the string "Hello, World!" in Python?
    1. print('Hello, World!')
    2. print("Hello, World!")
    3. print("Hello, World!")
    4. All of the above
  2. What will be the output of the following code?
    print("Hello", "World", sep="-")
    1. Hello World
    2. Hello-World
    3. "Hello"-"World"
    4. Error
  3. What will be the output of the following code?
    print("Hello", end="!")
    print("World")
    1. Hello\nWorld
    2. HelloWorld
    3. Hello!World
    4. Hello !World
  4. What is the purpose of the `sep` argument in the `print()` function?
    1. Specifies the string to print at the end of the output.
    2. Specifies the separator between the printed values.
    3. Specifies the string to print at the beginning of the output.
    4. Specifies the number of spaces between the printed values.
  5. What will be the output of the following code?
    x = 10
    y = 5
    print(f"The sum of {x} and {y} is {x + y}")
    1. The sum of x and y is x + y
    2. The sum of 10 and 5 is 15
    3. The sum of {x} and {y} is {x + y}
    4. Error
  6. How can you print a floating-point number with two decimal places using an f-string?
    1. print(f"{number:.2f}")
    2. print(f"{number:2f}")
    3. print(f"{number:.ff}")
    4. print(f"{number:f2}")
  7. What will be the output of the following code?
    print("This", "is", "a", "test", sep=" ", end=".")
    1. This is a test
    2. This is a test.
    3. This,is,a,test.
    4. This is a test\n
Click to see Answers
  1. D
  2. B
  3. C
  4. B
  5. B
  6. A
  7. B

Join the discussion

Please log in to post your answer.

Log In

Earn 2 Points for answering. If your answer is selected as the best, you'll get +20 Points! ๐Ÿš€