0% found this document useful (0 votes)
11 views1 page

What Is Indentation

Indentation refers to the use of spaces or tabs at the start of a line of code, crucial in Python for defining code blocks. It is necessary for proper execution, as incorrect indentation leads to an IndentationError, and it enhances code readability. Unlike languages like Java or C++, Python relies solely on indentation to determine the structure of the code.

Uploaded by

galandedikasha03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

What Is Indentation

Indentation refers to the use of spaces or tabs at the start of a line of code, crucial in Python for defining code blocks. It is necessary for proper execution, as incorrect indentation leads to an IndentationError, and it enhances code readability. Unlike languages like Java or C++, Python relies solely on indentation to determine the structure of the code.

Uploaded by

galandedikasha03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

What is Indentation?

Indentation means adding spaces or tabs at the beginning of a line of code.

In many programming languages (like Java or C++), code blocks are defined using braces {}. But in
Python, code blocks are defined only by their indentation level.

Significance of Indentation in Python

1. Defines code blocks

o It tells Python which lines of code belong together—like inside an if statement, loop,
function, or class.

2. Required for proper execution

o Incorrect indentation will raise an IndentationError.

3. Improves readability

o Python enforces clean and consistent formatting, making code easier to read and
maintain.

Example: With Proper Indentation

if 5 > 3:

print("Five is greater than three")

Example: Without Indentation (Error)

if 5 > 3:

print("Five is greater than three")

Output:

IndentationError: expected an indented block

You might also like