Free ATS Friendly Resume Builder Online

Create Your Resume

Resume Builder

Resume Maker

Resume Templates

Resume PDF Download

Create Your Resume is a free online resume builder that helps job seekers create professional, ATS friendly resumes in minutes. Easily build, customize, and download modern resume templates in PDF format.

Our resume maker is designed for freshers and experienced professionals looking to create job-ready resumes. Choose from multiple resume templates, customize sections, and generate ATS optimized resumes online for free.

Create resumes for IT jobs, software developers, freshers, experienced professionals, managers, and students. This free resume builder supports CV creation, resume PDF download, and online resume editing without signup.

Back to Python
Lesson 2 of 17

What Are Python Syntax, Indentation Rules, Keywords, and Identifiers?

Python syntax, indentation rules, keywords, and identifiers form the absolute foundation of writing correct and readable Python code. Unlike many programming languages that rely on braces or semicolons, Python uses indentation and clean syntax to define structure. This design choice forces clarity and consistency, making Python code easier for humans to read and maintain. Understanding Python syntax helps you write valid instructions that the interpreter can understand. Indentation rules control how code blocks behave, while keywords define Python’s built-in language commands. Identifiers allow you to name variables, functions, and objects meaningfully. This topic is critical because even small mistakes—such as incorrect indentation or invalid naming—can cause errors or unexpected behavior. Mastering these fundamentals early prevents confusion later and builds strong habits for writing professional, readable, and error-free Python programs.

Understanding Python Syntax

Python syntax refers to the set of rules that define how Python programs are written and interpreted. Python is designed to look clean and natural, reducing visual noise like braces and semicolons.

A Python statement usually represents a single instruction. Code is executed line by line, from top to bottom.

Example of Simple Python Syntax

print("Hello, Python")
x = 10
y = x + 5

There are no semicolons, no type declarations, and no block-ending symbols. This simplicity is intentional.

Indentation Rules in Python

Indentation is not optional in Python. It is how Python understands code structure.

Instead of using curly braces {}, Python uses indentation (whitespace) to define blocks of code.

Why Indentation Matters

  • Defines code blocks
  • Controls execution flow
  • Improves readability
  • Prevents ambiguous logic

Correct Indentation Example

if age >= 18:
    print("Eligible to vote")
    print("Access granted")

Incorrect Indentation Example

if age >= 18:
print("Eligible to vote")

The above code will raise an IndentationError because Python cannot determine the block structure.

Indentation Rules You Must Follow

  • Use consistent indentation (spaces or tabs, not both)
  • Recommended indentation is 4 spaces
  • All statements in a block must align

Indentation and Control Structures

Indentation becomes critical in conditional statements, loops, and functions.

Indentation with Conditionals

if score >= 50:
    print("Pass")
else:
    print("Fail")

Indentation with Loops

for i in range(3):
    print(i)

Indentation with Functions

def greet(name):
    return "Hello " + name

What Are Python Keywords?

Python keywords are reserved words that have predefined meanings in the language. They cannot be used as variable names, function names, or identifiers.

Keywords define Python’s grammar and control logic.

Examples of Common Python Keywords

  • if, else, elif
  • for, while, break, continue
  • def, return
  • class
  • try, except, finally
  • True, False, None

Why Keywords Are Restricted

Keywords are reserved because Python needs them to understand program structure. Allowing them as identifiers would create ambiguity.

Invalid Keyword Usage Example

def = 10

This will cause a SyntaxError because def is a Python keyword.

What Are Identifiers in Python?

Identifiers are names used to identify variables, functions, classes, and objects in Python.

They allow humans to label and reuse data meaningfully.

Valid Identifier Examples

age
user_name
calculate_total
StudentRecord

Rules for Naming Identifiers

  • Must start with a letter or underscore (_)
  • Cannot start with a number
  • Can contain letters, digits, and underscores
  • Cannot be a Python keyword
  • Case-sensitive

Invalid Identifier Examples

2name
total-amount
class

Case Sensitivity in Identifiers

Python is case-sensitive. This means uppercase and lowercase names are different.

value = 10
Value = 20

These are two different identifiers.

Best Practices for Identifiers

  • Use meaningful names
  • Follow snake_case for variables and functions
  • Use PascalCase for class names
  • Avoid single-letter names except for counters

Keywords vs Identifiers Comparison

Aspect Keywords Identifiers
PurposeDefine language structureName variables and objects
User-definedNoYes
Can be renamedNoYes

Real-World Perspective

Poor indentation and unclear identifiers are among the most common causes of beginner frustration. Professionally written Python code relies heavily on clean indentation and meaningful naming to remain readable years later.

Summary

Python syntax is designed for clarity, and indentation is the backbone of its structure. Keywords define what Python understands, while identifiers define what humans control. Mastering these rules early ensures clean, readable, and error-free code. These fundamentals are not optional— they are the language itself.