What are python libraries?
Python libraries are collections of pre-written code that provide functions, methods, and classes to perform specific tasks, eliminating the need to write code from scratch. Libraries extend Python's capabilities by offering solutions for various domains such as data analysis, web development, machine learning, DevOps automation, and more
Types of Python Libraries
Standard Libraries
These come pre-installed with Python and cover a wide range of functionalities like file handling, OS interaction, mathematics, and more.
Examples:os
: OS-level interactionssys
: System-specific parameters and functionsmath
: Mathematical operationsdatetime
: Date and time manipulationjson
: Handling JSON data
Third-Party Libraries
These are external libraries created by the community or organizations, installed via tools likepip
.
Examples:requests
: HTTP requestsnumpy
: Numerical computationspandas
: Data manipulation and analysisboto3
: AWS service automationFlask
: Web application development
Domain-Specific Libraries
Libraries tailored for specific fields or tasks.
Examples:Data Science:
matplotlib
,seaborn
,scikit-learn
DevOps:
boto3
,paramiko
,docker
Web Development:
Django
,Flask
Machine Learning:
TensorFlow
,PyTorch
Database Interaction:
sqlalchemy
,psycopg2
Tasks
Create a Dictionary in Python and write it to a json File.
Read a json file
services.json
kept in this folder and print the service names of every cloud service provider.{ "services": { "debug": "on", "aws": { "name": "EC2", "type": "pay per hour", "instances": 500, "count": 500 }, "azure": { "name": "VM", "type": "pay per hour", "instances": 500, "count": 500 }, "gcp": { "name": "Compute Engine", "type": "pay per hour", "instances": 500, "count": 500 } } }
output
aws : ec2
azure : VM
gcp : compute engine
Read YAML file using python, file
services.yaml
and read the contents to convert yaml to json
services: debug: 'on' aws: name: EC2 type: pay per hour instances: 500 count: 500 azure: name: VM type: pay per hour instances: 500 count: 500 gcp: name: Compute Engine type: pay per hour instances: 500 count: 500