Variable Declaration
A variable that stores data temporarily in Python (e.g.,
name = 'John'
).
Data Types
Different types of data in Python (e.g., integers, floats, strings,
booleans).
String
A sequence of characters (e.g., 'Hello, World!'
).
Integer
A whole number (e.g., 5
).
Float
A decimal number (e.g., 5.5
).
Boolean
A logical value (e.g., True
or False
).
Function Definition
Defines a reusable block of code (e.g., def greet():
).
Comments
Code comments that are ignored by the interpreter (e.g.,
# This is a comment
).
Conditionals
A set of instructions that are executed based on a condition (e.g.,
if x > 10:
).
Loops
A set of instructions that are repeatedly executed (e.g.,
for item in list:
).
Recursion
A function that calls itself (e.g., def factorial(n):
).
Object-Oriented Programming
A programming paradigm based on the concept of "objects" that
can contain data and methods (e.g., class Car:
).
Exception Handling
A mechanism to handle errors in a program (e.g.,
try/except
).
Regular Expressions
A powerful tool for pattern matching and manipulation in text (e.g.,
import re
).
Module
A file containing Python code that can be imported into another file (e.g.,
import my_module
).
Function Definition
Defines a reusable block of code (e.g., def greet():
).
Function Call
Executes a function (e.g., greet()
).
if-else
A conditional statement for decision-making (e.g., if x > 10:...
).
for
A loop to iterate over a sequence (e.g., for item in list:
).
while
A loop that repeats as long as a condition is true (e.g.,
while x < 10:
).
Class Definition
Defines a class blueprint in OOP (e.g., class Car:
).
List
An ordered collection of items (e.g., my_list = [1, 2, 3]
).
Dictionary
A collection of key-value pairs (e.g.,
my_dict = {'key': 'value'}
).
Tuple
An immutable collection of items (e.g., my_tuple = (1, 2, 3)
).
Set
A collection of unique items (e.g., my_set = {1, 2, 3}
).
Lambda Function
A small anonymous function (e.g., lambda x: x * 2
).
try-except
Handles exceptions in code (e.g., try: ... except:
).
Import
Imports modules or packages (e.g., import math
).
Range
Generates a sequence of numbers (e.g., range(1, 10)
).
List Comprehension
Creates a new list from an existing one (e.g.,
[x*2 for x in range(5)]
).
Map
Applies a function to all items in an iterable (e.g., map(str, list)
).
Reduce
Applies a function to all items in an iterable and returns a single value (e.g.,
reduce(lambda x, y: x + y, list)
).
List Sorting
Sorts a list in ascending or descending order (e.g.,
sorted(list)
).
List Indexing
Accesses an item in a list by its index (e.g., list[0]
).
List Concatenation
Combines two or more lists (e.g.,
list1 + list2
).
List Membership
Checks if an item is in a list (e.g., 1 in list
).
List Deletion
Removes an item from a list (e.g., del list[0]
).
List Insertion
Adds an item to a list at a specific index (e.g.,
list.insert(0, 'new item')
).
List Updating
Replaces an item in a list (e.g., list[0] = 'new item'
).
List Comprehension
Creates a new list from an existing one (e.g.,
[x*2 for x in range(5)]
).
List Indexing
Accesses an item in a list by its index (e.g., list[0]
).
List Concatenation
Combines two or more lists (e.g.,
list1 + list2
).
List Membership
Checks if an item is in a list (e.g., 1 in list
).
Filter
Filters elements based on a condition (e.g.,
filter(lambda x: x > 5, list)
).
Global and Local Variables
Scope rules for variables (e.g., global x
).
Decorator
A function that modifies the behavior of another function (e.g.,
@my_decorator
).
Inheritance
A way to derive new classes from existing ones (e.g.,
class Child(Parent):
).
Polymorphism
A way to have multiple classes that can behave similarly (e.g.,
class Animal(object):
).
Encapsulation
A way to hide the internal details of a class (e.g.,
class MyClass(object):
).
Abstraction
A way to hide the implementation details of a class (e.g.,
class MyClass(object):
).
Interface
A way to define a common set of methods and properties (e.g.,
class MyInterface(object):
).
Static Method
A method that does not access any instance variables (e.g.,
class MyClass(object):
).
File Handling
Reading and writing to files (e.g., open('file.txt', 'r')
).
List Slicing
Accesses parts of a list (e.g., my_list[1:4]
).
List Sorting
Sorts a list in ascending or descending order (e.g.,
sorted(list)
).
Zip
Combines elements from multiple iterables (e.g., zip(list1, list2)
).
Recursion
A function that calls itself (e.g., def factorial(n): ...
).