Question

Problems:

1. Write a python program that reads the data.csv file and plots the y variable and perform the

following tasks:

a. How many samples exists in the dataset? Use the len() function.

b. Find the mean of the dataset and display on the console.

c. Find the minimum of the dataset and display on the console.

d. Find the maximum of the dataset and display on the console.

e. Find the variance of the dataset and display on the console.

f. Find the median of the dataset and display on the console.

g. Find the standard deviation of the dataset and display on the console.

2. Using the same dataset as problem 1, plot the first 500 samples of the dataset. Add an

appropriate title, x-label, y-label, and legend to the plot. Make sure that the x axis shows the

samples 1-500.

3. Using the same dataset as problem 1, plot the last 500 samples of the dataset. Add an

appropriate title, x-label, y-label, and legend to the plot. Make sure that the x axis shows the

samples 9500-10000.

4. Using the same dataset as problem 1, plot the histogram of all samples in the dataset. Add an

appropriate title, x-label, y-label, and legend to the plot. Hint: You can use plt.hist().

5. Plot the following two lines on one graph for 100 samples of x between -2 and 2./na.

b.

y-axis

C. Make the x-label 'x' and the y-label 'y'.

d. Find the approximate coordinate of the point where the two lines intersect. What is the

meaning of this point?

e.

Mark the point of intersection on the graph a red *.

f. Create a legend that shows the corresponding color for the two lines and the point.

The final answer question should look like:

6

4

2

0

-2

y1 = -2x + 2

y2 = 2x - 2

9

Turn on the grid for the graph.

Make the title "Two-line Plot".

-2.0 -1.5

Two line plot

-1.0 -0.5

0.0 0.5

x-axis

1.0

• |||

yl

y2

point

1.5 2.0/n6. Plot the following two functions on one graph for 100 samples of x between -2 and 2.

y1 - 2.5x + 2 = 0

y2- x^3+2=0

a. Turn on the grid for the graph.

b. Make the title "Two functions plot".

c. Make the x-label 'x' and the y-label 'y'.

d.

Find the approximate coordinates of the points where y1 and y2 intersect (there are

more than one. What is the meaning of these points?

e. Plot the points on the graph of the two functions with red, blue, and magenta colors and

the * symbol.

f.

Create a legend that shows the corresponding colors for the two lines and the points of

intersection./n7. Write a python program that creates a sinusoidal function with f=60Hz for a 1 second duration.

Use a step size of T/100 where, T is the period of one cycle (1/f). Use the below.

First, calculate t (not T) by using np.arange. Your start value will be 0, the stop value will

be T (1 cycle), and the step will be as specified above. This will then provide the points

of amplitude for the duration of 1 cycle.

Then calculate y = (sin(2pi*f*t)

Add an appropriate title, x-label, y-label, and legend to the graph. Plot only the first oscillation.

Your final graph should be look like the graph below. Note the time scale is in ms.

Fundamental harmonic f=60Hz

Magnitdue

1.0

0.5-

0.0-

-0.5

-1.0

0.0

2.5

5.0

7.5

10.0

12.5

f=60Hz

15.0

Question image 1Question image 2Question image 3Question image 4