Python Syntax and Basics

Python syntax is clean and easy to read. It uses indentation instead of brackets to define code blocks, making it beginner-friendly. Understanding the basics like print statements, variables, and comments is essential to start coding in Python.

Python Syntax and Basics – AskPrep Blog
Python Tutorial
Apr 14, 2025
By Kavya dhar
Python Syntax and Basics - AskPrep

Python Syntax and Basics

Python uses simple and readable syntax. Unlike other programming languages, Python does not use curly braces. Instead, it relies on indentation to define blocks of code.

1. Print Statement

Use the print() function to display output:

print("Hello, World!")

2. Variables

Variables are created when you assign a value to them:

x = 5
y = "AskPrep"
print(x)
print(y)

3. Indentation

Python uses indentation to indicate blocks of code:

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

4. Comments

You can write comments using the # symbol:

# This is a comment
print("This is code")
K
Instructor / Author

Kavya

None

More Courses by Kavya

More Blogs by Kavya