
Python Syntax
Python syntax means the basic rules used to write Python code. The syntax is simple, which makes Python easy for beginners to learn.
Basic Example
print("Hello, World!")This code prints:
Hello, World!Indentation
Python uses spaces to show which code belongs to a particular block.
if age >= 18:
print("You are an adult")The spaces before print() are important. Incorrect indentation can cause an error.
Variables
Variables are used to store values.
name = "Vishnu"
age = 21
print(name)
print(age)Comments
Comments are used to explain code. They start with #.
# This is a comment
print("Hello")Python ignores comments when running the program.
Case Sensitive
Python treats uppercase and lowercase letters differently.
name = "Vishnu"
Name = "Rahul"Here, name and Name are two different variables.
Colon :
A colon is used before a block of code, such as with if, for, while, functions, and classes.
if age >= 18:
print("Eligible")Join Techsnap Creators
Share your knowledge and earn ??
Want to showcase your tech expertise and get rewarded for your insights? Join the Techsnap creator network!
Write insightful blogs, stay ahead of industry trends, and grow your professional brand while helping others in the community.
Ready to make an impact?

Comments