HOME
ABOUT

Python Syntax Basics

Python Syntax Basics

Indentation

Python uses indentation to define code blocks instead of curly braces.

if 5 > 2:
    print("Five is greater than two!")

Comments

# This is a single-line comment

"""
This is a
multi-line comment
"""

Variables

x = 5       # Integer
y = "Hello" # String

Print Function

print("Hello World")
print(1, 2, 3, sep="-")  # Output: 1-2-3

Multi-line Statements

total = 1 + \
        2 + \
        3

Related Articles

  • Introduction to Python
  • Setting Up Python Environment
  • Python Syntax Basics
  • Variables and Data Types
  • Operators
  • Input and Output
  • Control Flow: Conditionals
  • Control Flow: Loops
  • Functions
  • Lists and Tuples
  • Dictionaries and Sets
  • String Manipulation
  • How to execute SQL queries (Select, Update, Insert, Delete) effectively using Python?