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")