Python Language Learning Guide
Python is a popular, high-level programming language known for its simplicity and versatility. It is
widely used in web development, data science, AI, automation, and more.
# Installing Python:
1. Download Python from https://www.python.org/
2. Install it and ensure 'pip' (package manager) is installed.
3. Check installation using: python --version
# Basic Syntax:
- Print statement: print("Hello, World!")
- Variables: x = 10, name = "Anurag"
- Comments: # This is a comment
Python uses indentation instead of curly braces to define blocks.
Core Python Concepts
# Data Types:
- int, float, str, list, tuple, dict, set, bool
# Operators:
- Arithmetic: +, -, *, /, %
- Comparison: ==, !=, >, <, >=, <=
# Loops:
for i in range(5):
print(i) # Prints 0 to 4
while condition:
# Loop until condition is False
# Functions:
def greet(name):
return "Hello, " + name
print(greet("Anurag"))
Advanced Python Topics
# Object-Oriented Programming (OOP):
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def introduce(self):
return f"My name is {self.name}, and I am {self.age} years old."
p1 = Person("Anurag", 22)
print(p1.introduce())
# File Handling:
with open("file.txt", "w") as f:
f.write("Hello, Python!")
# Libraries:
import math
print(math.sqrt(16)) # Output: 4.0
Python is powerful and beginner-friendly. Keep practicing to master it!