Bird
0
0

You want to temporarily disable a block of code without deleting it. Which is the best way to do this in Python?

hard📝 Application Q15 of 15
Python - Basics and Execution Environment
You want to temporarily disable a block of code without deleting it. Which is the best way to do this in Python?
APut # at the start of each line in the block
BSurround the code block with triple quotes ''' ... '''
CUse /* ... */ around the block
DWrap the block in <!-- ... -->
Step-by-Step Solution
Solution:
  1. Step 1: Understand Python comment styles for disabling code

    Python does not officially support block comments; the common way is to put # at the start of each line.
  2. Step 2: Evaluate triple quotes usage

    Triple quotes create a string literal, which may not disable code properly and can cause unexpected behavior if used improperly.
  3. Step 3: Recognize other language comment styles

    Options C and D are not valid in Python.
  4. Final Answer:

    Put # at the start of each line in the block -> Option A
  5. Quick Check:

    Disable code block = # per line [OK]
Quick Trick: Use # on each line to disable code safely [OK]
Common Mistakes:
MISTAKES
  • Using triple quotes which may not disable code
  • Using /* */ which is invalid in Python
  • Using HTML comments which do nothing in Python

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes