import requests from bs4 import BeautifulSoup url = "https://www.example.com" response = requests.get(url) html = response.content soup = BeautifulSoup(html, 'html.parser') links = soup.find_all('a') for link in links: print(link.get('href'))
import pandas as pd data = { 'name': ['Alice', 'Bob', 'Charlie', 'David'], 'age': [25, 35, 45, 55], 'salary': [50000, 70000, 90000, 110000] } df = pd.DataFrame(data) avg_salary = df['salary'].mean() print(avg_salary)
from sklearn.svm import SVC from sklearn.metrics import accuracy_score from sklearn.model_selection import train_test_split from sklearn.datasets import load_iris iris = load_iris() X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.3) model = SVC() model.fit(X_train, y_train) y_pred = model.predict(X_test) accuracy = accuracy_score(y_test, y_pred) print(accuracy)Package library used: Scikit-Learn In summary, Python environment refers to the tools and libraries used for developing, testing and running Python code. The choice of package libraries depends on the specific functionality needed, such as data analysis, web scraping, or machine learning. The examples above use popular package libraries such as Beautiful Soup, Pandas and Scikit-Learn to perform different tasks.