PH3094D Computational Lab_Exercise3
PH3094D Computational Lab_Exercise3
Exercise-3
6. Array Manipulation:
● Objective: Create an array of 10 random integers between 1 and 50.
● Reshape the array into a 2x5 matrix.
● Find the minimum and maximum values in the array.
● Calculate the mean and standard deviation of the array.
7. Array Indexing and Slicing:
● Objective: Create an array of 20 random numbers.
● Extract the first 5 elements of the array.
● Extract every third element of the array.
● Create a new array containing only the even-indexed elements.
8. Array Filtering:
● Objective: Create an array of 15 random numbers.
● Find all elements in the array that are greater than 5.
● Find all elements in the array that are between 10 and 20.
9. Array Sorting and Searching:
● Objective: Create an array of 12 random numbers.
● Sort the array in ascending order.
● Find the indices of the sorted array.
● Find the index of the value 7 in the array (if it exists).
10. Sine Wave Visualization:
● Objective: Create a plot of the sine function over a specified interval.
● Instructions:
○ Use numpy.linspace() to generate an array of x-values.
○ Calculate the corresponding y-values using numpy.sin().
○ Use matplotlib.pyplot.plot() to create a line plot.
○ Add labels to the x-axis and y-axis, and a title to the plot.
11. Bar Chart for Student Grades:
● Objective: Create a bar chart to visualize the distribution of student grades in a
class.
● Instructions:
○ Create a list or array of student grades.
○ Use matplotlib.pyplot.bar() to create a bar chart.
○ Set appropriate labels for the x-axis (e.g., student names) and y-axis
(grades).
○ Add a title to the plot.
12. Scatter Plot for Height and Weight:
● Objective: Create a scatter plot to visualize the relationship between height and
weight of a group of individuals.
● Instructions:
○ Create two lists or arrays: one for heights and one for corresponding
weights.
○ Use matplotlib.pyplot.scatter() to create a scatter plot.
○ Set appropriate labels for the x-axis (height) and y-axis (weight).
○ Add a title to the plot.
13. Histogram for Age Distribution:
● Objective: Create a histogram to visualize the distribution of ages in a population.
● Instructions:
○ Create a list or array of ages.
○ Use matplotlib.pyplot.hist() to create a histogram.
○ Set appropriate labels for the x-axis (age) and y-axis (frequency).
○ Add a title to the plot.
14. Subplots for Multiple Plots:
● Objective: Create a figure with multiple subplots to visualize different aspects of a
dataset.
● Instructions:
○ Create a figure using matplotlib.pyplot.figure().
○ Add subplots using matplotlib.pyplot.subplot().
○ In each subplot, create a different type of plot (e.g., line plot, bar chart,
scatter plot) using the appropriate data.
○ Set appropriate labels and titles for each subplot.