Practice For Lesson 4-3

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Practices for Lesson 4:

Using Python in Data Science

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved
1 Practices for Lesson 4: Using Python in Data Science
Practices for Lesson 4
Overview
In these practices for this lesson, you will learn to install Anaconda, configure Anaconda, launch
Jupyter Notebook, process different types of data, create visualizations using few chart
properties and implement Chi-square algorithm.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved
2 Practices for Lesson 4: Using Python in Data Science
Practice of 4-3: Creating visualizations by using chart properties and
chart styling
Overview
In this practice, you will learn to create charts and style the charts using Python libraries.

Assumptions: You should have completed the Practices for 4-2


Tasks:
1. Open your Jupyter Notebook and save the file as charts.
2. Creating sine wave in Jupyter Notebook
a. Copy the below code and paste it in Jupyter Notebook cell to plot sine wave for 4
cycle as shown below. Click Run icon.

# sine wave for 4 cycle


import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0, 8 * np.pi, 0.1)


y = np.sin(x)
plt.title("sine wave form")
# Plot the points using matplotlib
plt.plot(x, y, 'g')
plt.show()

b. On successful execution, view the sine wave displayed below your code cell as
shown below.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved
3 Practices for Lesson 4: Using Python in Data Science
3. Create bar graph in Jupyter Notebook
a. Copy the below code and paste it in Jupyter Notebook cell to plot bar graph as
shown below. Click Run icon.

# Bar Graph
import matplotlib.pyplot as plt

left = [1, 2, 3, 4, 5, 6, 7, 8]

bar_height = [12, 25, 36, 30, 40, 16, 42, 20]

tick_label = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']

plt.bar(left, bar_height, tick_label = tick_label, width =


0.8, color = ['green', 'blue'])

plt.title('Bar Graph')
# function to show the plot
plt.show()

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved
4 Practices for Lesson 4: Using Python in Data Science
b. On successful execution, view the bar graph displayed below your code cell as
shown below.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved
5 Practices for Lesson 4: Using Python in Data Science
4. Creating a pie chart in jupyter Nodebook
a. Copy the below code and paste it in Jupyter Notebook cell to plot the pie chart as
shown below. Click Run icon.

import matplotlib.pyplot as plt

lessons = ['EVS', 'Maths', 'English', 'Hindi']

slices = [3, 7, 8, 6]

colors = ['r', 'b', 'g', 'y']

plt.pie(slices, labels = lessons, colors=colors,


startangle=90, shadow = True, explode = (0, 0, 0.1, 0),
radius = 2, autopct = '%1.1f%%')
plt.title('Pie Chart')
plt.legend()

plt.show()

b. On successful execution, view the pie chart displayed below your code cell as
shown below.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved
6 Practices for Lesson 4: Using Python in Data Science
5. Close the Jupyter Notebook.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved
7 Practices for Lesson 4: Using Python in Data Science

You might also like