Mechanical

Uploaded on

24 Nov 2022

Skill-Lync

Indentation refers to the spaces at the starting of a line of code. While in other programming languages the indentation in code is for readability alone, the indentation in Python has much more significance.

Simply, put an indentation helps the interpreter distinguish a block of code. A Python interpreter can be informed that a group of statements belongs to a specific block of code by using Python indentation. Any combination of these assertions is known as a block. The grouping of statements into a block might be thought of as serving a specific function. Braces are commonly used in programming languages like C, C++, and Java to define code blocks. Python employs indentation to draw attention to the code chunks. Python uses whitespace to indicate indentation. The same block of code contains all statements spaced to the right by the same amount. A block is simply indented further to the right if it needs to be more deeply nested.

**If any of the spaces are not given or aren't properly aligned python will display the ‘indentation error’ as shown above.**

**Also, a mismatched number of spaces with the lines inside the loop will throw the indentation error as above.**

**If the spaces have been mixed with tab and spacebar spaces while providing indentation python will throw up the error as above.**

**EXAMPLES:**

**Indentation is not given for the above code and so the block(for loop) will be left unindented and the following error will show up.**

**SOLUTION:**

- Proper indentation should be provided as shown below,

- Here the line “B.append(c)” is not having the same indentation as the line above, which throws up the indentation error as below,

**SOLUTION:**

- The number of spaces should be matching with all the lines in the same block and no matter how many spaces we are using but it should be constant over the block as shown below.

- Here the spaces given in the lines are inconsistent which includes the spaces using both tab spaces and space bar, which makes up the indentation error.

**SOLUTION:**

- Using uniform spaces for the indentation with either using a tab space or a space bar avoids indentation errors.

Author

Navin Baskar

Author

Skill-Lync

Continue Reading

**Related Blogs**

Moving Frame of Reference

A Moving Reference Frame (MRF) is a very straightforward, reliable, and effective steady-state Computational Fluid Dynamics (CFD) modeling tool to simulate rotating machinery. A quadcopter's rotors, for instance, can be modeled using MRFs.

Mechanical

12 May 2023

Analysis Settings in Ansys Software

Analysis settings in Ansys are the parameters which determine how the simulation should run.

Mechanical

08 May 2023

Comparing the Explicit and Implicit Methods in FEA

In Ansys, the analysis settings play a very important role in converging the solution and obtaining the results. These involve settings about the timestep size, solver type, energy stabilization etc.

Mechanical

06 May 2023

Tensors, Stress, and 2D Meshing: A Primer for Beginners

A tensor is a mathematical object that describes a geometric relationship between vectors, scalars, and other tensors. They describe physical quantities with both magnitude and direction, such as velocity, force, and stress.

Mechanical

05 May 2023

Reynold's law of Similarity

The Reynolds number represents the ratio of inertial to viscous forces and is a convenient parameter for predicting whether a flow condition will be laminar or turbulent. It is defined as the product of the characteristic length and the characteristic velocity divided by the kinematic viscosity.

Mechanical

04 May 2023

Author

Skill-Lync

Continue Reading

**Related Blogs**

Moving Frame of Reference

A Moving Reference Frame (MRF) is a very straightforward, reliable, and effective steady-state Computational Fluid Dynamics (CFD) modeling tool to simulate rotating machinery. A quadcopter's rotors, for instance, can be modeled using MRFs.

Mechanical

12 May 2023

Analysis Settings in Ansys Software

Analysis settings in Ansys are the parameters which determine how the simulation should run.

Mechanical

08 May 2023

Comparing the Explicit and Implicit Methods in FEA

In Ansys, the analysis settings play a very important role in converging the solution and obtaining the results. These involve settings about the timestep size, solver type, energy stabilization etc.

Mechanical

06 May 2023

Tensors, Stress, and 2D Meshing: A Primer for Beginners

A tensor is a mathematical object that describes a geometric relationship between vectors, scalars, and other tensors. They describe physical quantities with both magnitude and direction, such as velocity, force, and stress.

Mechanical

05 May 2023

Reynold's law of Similarity

The Reynolds number represents the ratio of inertial to viscous forces and is a convenient parameter for predicting whether a flow condition will be laminar or turbulent. It is defined as the product of the characteristic length and the characteristic velocity divided by the kinematic viscosity.

Mechanical

04 May 2023

Book a Free Demo, now!

Related Courses

4.9

495 Hours of content

Electrical Domain

Recently launched

0 Hours of content

Cae Domain

5

0 Hours of content

Design Domain

Showing 1 of 6 courses

Try our top engineering courses, projects & workshops today!Book a Live Demo