Problem 1
NumPy (Numerical Python)
Purpose: NumPy is fundamental for scientific computing with Python. It contains among other things a powerful N-dimensional array object and useful linear algebra, Fourier transform, and random number capabilities.
- numpy.array()
: Creates an n-dimensional array. It is the foundation of NumPy, allowing for the performance of mathematical operations on arrays.
- numpy.linspace()
: Returns evenly spaced numbers over a specified range, and it’s quite helpful in generating data points for plotting.
Pandas
Purpose: Pandas offer data structures and operations for manipulating numerical tables and time series, which makes it suitable for data cleaning and analysis.
- pandas.DataFrame()
: A two-dimensional, size-mutable, and potentially heterogeneous tabular data structure with labeled axes (rows and columns).
- pandas.read_csv()
: Reads a comma-separated values (csv) file into DataFrame, a common method for importing data from spreadsheets or databases.
Matplotlib
Purpose: Matplotlib is a 2D plotting library for creating static, animated, and interactive visualizations in Python.
- matplotlib.pyplot.plot()
: Basic plotting function that allows for the creation of a variety of plots quickly.
- matplotlib.pyplot.figure()
: Creates a new figure, which can be useful when generating multiple plots in the same script.
Problem 2
API: OpenWeatherMap API Type of API: RESTful API What it does: Provides weather data, which includes current weather, forecasts, nowcasts and historical weather data for any location in the world. Unique Feature: It has a One Call API endpoint that allows you to retrieve current, minutely, hourly, and daily weather forecasts using a single API call. Brainstorm Scenario: A potential application could be a personalized daily weather forecast notification system. Users receive notifications about the weather conditions of the day at their location, helping them plan their daily activities better.
Problem 3
import numpy as np # Importing the numpy library and giving it a prefix np
# Creating an array of 10 numbers
array = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
# Using a prefixed function (np.mean)
# Calculating the mean of the array
mean_value = np.mean(array) # The mean_value will hold the average of the numbers in the array
# Using a prefixed variable (np.pi)
# Creating an array of numbers multiplied by pi
array_times_pi = array * np.pi # np.pi represents the mathematical constant π (pi)
# Displaying the results
print(f"Original array: {array}")
print(f"Mean of the array: {mean_value}")
print(f"Array multiplied by pi: {array_times_pi}")