CompTIA Linux+ XK0-006 (V8) Practice Question

While reviewing a Python 3 script that inventories running services, you notice the author indented one line with a tab and the next with four spaces. Running the script immediately raises:

TabError: inconsistent use of tabs and spaces in indentation

The developer also wants to make the code conform to the PEP 8 style guide. Which modification will resolve the error and satisfy PEP 8 recommendations?

  • Convert the file's line endings to LF (Unix style); inconsistent CRLF endings are what trigger the TabError.

  • Replace every indentation level with a single tab character; PEP 8 requires tabs rather than spaces.

  • Replace every indentation level with exactly four space characters and remove all tabs.

  • Add a shebang of #!/usr/bin/env python -tt so Python automatically treats tabs as four spaces at runtime.

CompTIA Linux+ XK0-006 (V8)
Automation, Orchestration, and Scripting
Your Score:
Settings & Objectives
Random Mixed
Questions are selected randomly from all chosen topics, with a preference for those you haven’t seen before. You may see several questions from the same objective or domain in a row.
Rotate by Objective
Questions cycle through each objective or domain in turn, helping you avoid long streaks of questions from the same area. You may see some repeat questions, but the distribution will be more balanced across topics.

Check or uncheck an objective to set which questions you will receive.

Bash, the Crucial Exams Chat Bot
AI Bot