The print() function is one of the first things every Python beginner learns. It is used to display text, numbers, variables, or the output of expressions on the screen.

Python is known for its simple syntax and easy-to-read code, making it one of the best programming languages for beginners.

Syntax

Explanation

print("Welcome to AHK Infotech")

print() is a built-in Python function.

Output

Text must be enclosed within single (' ') or double quotes.

Welcome to AHK Infotech

Python Print Statement and Indentation

Python Indentation – Learn Python Block Structure

Python uses indentation to define blocks of code instead of curly braces {} like many other programming languages. Indentation makes Python code clean, readable, and easy to understand. In standard Python coding practice, each block should be indented using 4 spaces.

Both tabs and spaces are supported by Python, but according to the PEP 8 Python Style Guide, developers should use 4 spaces for each indentation level to maintain consistency and avoid errors.

Syntax

Output

x is 1.

x = 1

if x == 1:

# Indented with four spaces

print("x is 1.")

  • The if statement checks whether the value of x is equal to 1.

  • The print() statement is indented by 4 spaces, making it part of the if block.

  • If the condition is True, Python executes the indented code.

  • Without proper indentation, Python will raise an IndentationError.

Best Practices for Python Indentation
  • Always use 4 spaces for indentation.

  • Avoid mixing tabs and spaces in the same file.

  • Use a modern code editor such as VS Code or PyCharm to automatically format indentation.

  • Follow the official Python coding style (PEP 8) for professional code.

Key Takeaways
  • Python uses indentation instead of curly braces to create code blocks.

  • The recommended indentation is 4 spaces.

  • Proper indentation is mandatory in Python and improves code readability.

  • Incorrect indentation will cause your program to fail with an error.

Explanation

Contact

Reach out for AI courses and support

Email

Phone

careers@ahkacademy.in

Mo:- +91-7769920076

}

© 2025. All rights reserved.