Python Libraries Overview
Python offers a vast ecosystem of libraries that provide ready-to-use functionality for various tasks like data manipulation, web development, machine learning, and more.
Python comes with a rich set of built-in libraries:
| Library | Purpose | Example |
|---|---|---|
math | Mathematical operations | math.sqrt(16) → 4.0 |
random | Random numbers | random.randint(1,10) |
datetime | Date and time | datetime.now() |
os | Operating system tasks | os.listdir() |
sys | System-specific parameters | sys.argv |
re | Regular expressions | re.search(r'\d+', text) |
json | JSON handling | json.loads() / json.dumps() |
csv | CSV file operations | csv.reader(file) |
time | Time-related functions | time.sleep(2) |
These libraries need to be installed via pip:
| Library | Purpose | Example |
|---|---|---|
NumPy | Numerical computations, arrays | np.array([1,2,3]) |
Pandas | Data manipulation & analysis | pd.DataFrame(data) |
Matplotlib | Data visualization | plt.plot(x, y) |
Seaborn | Statistical visualization | sns.heatmap(data) |
Requests | HTTP requests | requests.get(url) |
BeautifulSoup | Web scraping | BeautifulSoup(html, 'html.parser') |
TensorFlow / PyTorch | Machine learning | tf.keras.Model() |
scikit-learn | Machine learning algorithms | LinearRegression() |
OpenCV | Image & video processing | cv2.imread() |
Flask / Django | Web development | app = Flask(__name__) |
Installing:
Importing:
Example:
Python has built-in and third-party libraries for almost any task.
Use pip to install external libraries.
Libraries save development time and improve code efficiency.
Always check documentation for usage examples and functions.
Combining multiple libraries allows powerful and scalable applications.
Take quizzes related to this topic and see where you stand!
Start Quiz Now