Introduction to Python, Variables, and Syntax
What is Python?
-
Python is a high-level, interpreted programming language.
-
Used for web development, data science, AI, automation, and more.
-
Easy to learn, beginner-friendly, and very popular.
Features of Python
-
Simple & Easy → Looks like plain English.
-
Interpreted → Runs line by line.
-
Cross-platform → Works on Windows, Mac, Linux.
-
Huge Libraries → Ready-made tools for data, AI, web, etc.
-
Free & Open-source → Anyone can use and contribute.
Python File Extension
-
Python files are saved with the
.pyextension. -
Example:
hello.py
Python Environment (How to Run Python)
You can write and run Python code in:
-
VS Code / PyCharm – Popular code editors for developers.
Variables in Python
-
A variable is like a box that stores information.
-
Example:
name = "Harry" age = 11 print(name, age)
Rules for Naming Variables
Must start with a letter or underscore _.
Can contain letters, numbers, and _.
Case sensitive → Name and name are different.
Cannot use spaces or special characters.
Cannot use reserved words like for, while, class.
Python Syntax Rules
-
Indentation – Use spaces to define blocks of code.
if True: print("This is indented") -
Case Sensitivity – Python treats uppercase and lowercase differently.
Name = "Alice" print(Name) # Works print(name) # Error -
Comments – Notes for humans, ignored by Python.
# This is a comment ''' This is a multi-line comment ''' -
Print & Input – To show output and take input.
print("Hello, Python!") user = input("Enter your name: ") print("Welcome,", user)
Key Takeaway: Python is a simple, powerful, and widely used programming language. Understanding variables and syntax rules is the first step to writing correct code.
