# Quiz Module 4.1 ## How to make a chart ### Why we need visualization 1. What type of charts is useful to visualize data? - [ ] Pie chart - [ ] Historgram - [ ] Bar graph - [x] All of the above 2. What is NOT a reason to visualize data? - [ ] To show trends - [ ] To give a visual overview of the data - [x] To hinder human's decision-making ability ### How to make a chart (p1) 1. To illustrate the increasing rate of obesity in children over time, what type of plot should we use? - [ ] Bar graph - [x] Line chart - [ ] Bar historgram - [ ] Scatterplot 2. To determine the relationship between education and poverty level in certain countries, what type of plot should we use? - [ ] Bar graph - [ ] Line chart - [ ] Bar historgram - [x] Scatterplot 3. When should we use a pie chart? - [ ] To illustrate the relationships between variables - [ ] To show changes over time - [x] To illustrate the significant difference in components - [ ] To show the distribution of variables 4. What type of graph would work best to display the change in temperature in a city over time? - [ ] Bar - [ ] Pie - [ ] Histogram - [x] Line 5. What type of graph would work best to display the proportion of team members who own a cat, dog, bird, or no pet? (Assume each team member can only own one pet.) - [x] Pie - [ ] Line - [ ] Bar - [ ] Histogram 6. What type of chart is this? ![](https://i.imgur.com/Sp22fHJ.png) - [ ] Bar chart - [x] Histogram - [ ] Box plot - [ ] Scatterplot ### How to make a chart (p2) 1. What are the two libraries used for data visualization? - [ ] NumPy & Matplotlib - [x] Seaborn & Matplotlib - [ ] Numpy & Pandas - [ ] Pandas & Seaborn 2. Which kind of analysis and variable should be used for this scatterplot? ![](https://i.imgur.com/ls1jcJx.png) - [ ] Univariate - Continuous - [ ] Univariate - Categorical - [x] Bivariate - Continuous vs Continuos - [ ] Bivariate - Categorical vs Categorical ## Seaborn & Matplotlib ### Matplotlib: Creating subplots 1. Which line of code will create a figure with a height of 7 inches and a width of 6 inches? - [ ] plt.set_size([7,6]) - [x] plt.figure(figsize=(6, 7)) - [ ] plt.plot(x, y, size=(6, 7)) - [ ] plt.figsize(7, 6) 2. What is the command to create a figure with 3 rows and 2 columns, and a subplot in the second row and the first column? ![](https://i.imgur.com/tZWJJd8.png) - [ ] plt.subplot(3, 2, 2) - [x] plt.subplot(3, 2, 3) - [ ] plt.plot(2, 3, 3) - [ ] plt.figure(3, 2, subplot=3) 3. What is the correct way to show the result of the graph? - [ ] plt.plot() - [x] plt.show() - [ ] plt.paint() - [ ] plt.paint() 4. The recommanded way to load matplotlib library is - [x] import matplotlib.pyplot as plt - [ ] import matplotlib.pyplot - [ ] import matplotlib as plt - [ ] import matplotlib ### Matplotlib: Customizing a chart 1. The red box in the given image is called ![](https://i.imgur.com/8zxujNp.png) - [ ] Chart title - [ ] Markers - [x] Legend - [ ] Data series 2. What is the command to set x-axis ticks to be "Carbohydrates", "Lipids", "Protein"? - [ ] plt.set_xlabels("Carbohydrates", "Lipids", "Protein") - [x] plt.xticks(ticks = ["Carbohydrates", "Lipids", "Protein"]) - [ ] plt.xticks(["Carbohydrates", "Lipids", "Protein"]) - [ ] plt.xlabel(["Carbohydrates", "Lipids", "Protein"]) 3. The red box in the given image is called ![](https://i.imgur.com/RoubS5O.png) - [x] Chart title - [ ] Markers - [ ] Legend - [ ] Data series ### Matplotlib: Adding text 1. What's the purpose of plt.text()? - [ ] Add texts to the x and y-axis - [ ] Customize the styling of the x and y-axis labels - [x] Add texts to explain the charts better ## Correlation ### Correlation 1. If every woman married a man who was about 2 inches taller than she, what would the correlation between the heights of married men and women be? - [ ] Negative correlation - [ ] No correlation - [x] Positive correlation 2. What's the correlation of the variables shown in this scatterplot? ![](https://i.imgur.com/5PLRoLb.png) - [ ] Negative correlation - [x] No correlation - [ ] Positive correlation 3. Vivek notices that students in his class with larger shoe sizes tend to have higher grade point averages. Based on this observation, what is the best description of the relationship between shoe size and grade point average? - [ ] Causal relationship - [ ] Negative correlation - [ ] No correlation - [x] Positive correlation 4. The scatterplot above shows the price of a hot dog and a small drink at seventeen different baseball stadiums. Based on the scatterplot, which of the following statements is true? ![](https://i.imgur.com/BUAIPlR.png) - [x] There is a positive linear correlation between the price of hot dogs and soft drinks. - [ ] There is a negative linear correlation between the price of hot dogs and soft drinks. - [ ] There is no correlation between price of hot dogs and soft drinks. - [ ] An increase in the price of hot dogs causes an increase in the price of soft drinks. - [ ] The ballpark with the most expensive hot dog has the most expensive soft drink. 5. Which of the following would not be a correct interpretation of a correlation of r = –.30? - [ ] The variables are inversely related. - [x] 30% of the variation between the variables is linear. - [ ] There exists a weak relationship between the variables. - [ ] All of the above statements are correct. ## Working with Time ### Working with Time (p1) 1. What will be the output of the following code? ```python= pd.to_datetime("03/24/17") ``` - [ ] Error - [x] 2017-03-24 - [ ] 2017-3-24 - [ ] 24-3-2017 2. What is the correct way to extract the year in the series? ```python= birthday = pd.Series(['17th of Jan, 2007', '20/11/2019', '1940-11-04']) birthday = pd.to_datetime(birthday) ``` - [ ] birthday.year() - [ ] birthday.get(year) - [x] birthday.dt.year - [ ] dt.birthday.year 3. What is the correct output of the program? ```python= #17th Jan, 2007 is Wednesday, 20/11/2019 is Wednesday, 1940-11-04 is Monday birthday = pd.Series(['17th of Jan, 2007', '20/11/2019', '1940-11-04']) birthday = pd.to_datetime(birthday) birthday.dt.dayofweek ``` - [ ] [1, 2, 3] - [ ] [4, 4, 2] - [x] [2, 2, 0] - [ ] [04, 04, 02] ### Working with Time (p2) 1. Down sampling is the process of converting a ______________ to __________________ frequency - [ ] Low, High - [x] High, Low 2. What is the default aggregation function while resampling a time series in pandas - [ ] sum - [x] mean - [ ] order - [ ] groupby