7.2.6.Video quiz - quanganh2001/Google-Data-Analytics-Professional-Certificate-Coursera GitHub Wiki

Programming fundamentals

Question: Fill in the blank: In R, the _____ is information that a function needs to run.

A. argument

B. comment

C. operator

D. variable

The correct answer is A. argument. Explain: In R, the argument is information that a function needs to run.

In R, a variable name should begin with a number or an underscore.

A. True

B. False

It is false statement. Explain: A variable name can contain numbers and underscores, but it should begin with a letter.

Operators and calculations

Note: At closer glance, you will notice that the instructor highlighted the entire 4 lines of syntax together before running the code by pressing the "Run" button or pressing the hotkeys (PC : CTRL + Enter and Mac: CMND + Enter).

As an alternative option, you may separately run each line of code one at a time after typing the syntax. Follow these steps in the script editor:

# our first calculations (run the code)

quarter_1_sales <- 35657.98 # (run the code)

quarter_2_sales <- 43810.55 # (run the code)

midyear_sales <- quarter_1_sales + quarter_2_sales # (run the code)

Each variable will be committed to memory in the script editor before getting to the next line, so you won't receive an error when running the final line of code containing the midyear_sales variable.

A data analyst inputs the following calculation in their R programming: basket_1 * 20 + basket_2 * 15

Which arithmetic operators is the analyst using? Select all that apply.

  • Subtraction
  • Division
  • Addition
  • Multiplication

Explain: In the calculation basket_1 * 20 + basket_2 * 15, the analyst is performing arithmetic operations for addition using the addition operator (+) and for multiplication using the multiplication operator (*).

The gift that keeps on giving

Question: Fill in the blank: Packages in R include _____. Select all that apply.

  • sample datasets
  • reusable R functions
  • visualizations
  • tests for checking your code

Explain: Packages in R include reusable R functions, documentation about how to use the functions, sample datasets, and tests for checking your code.

Welcome to the tidyverse

Question: Tidyverse is a collection of packages in R with a common design philosophy.

A. True

B. False

It is true statement. Explain: Tidyverse is a collection of packages in R with a common design philosophy. The tidyverse packages are especially useful for data manipulation, exploration, and visualization.

More on the tidyverse

Questions: Which tidyverse package is used for data visualization?

A. readr

B. tidyr

C. dplyr

D. ggplot2

The correct answer is D. ggplot2. Explain: The ggplot2 package is used for data visualization, specifically plots. You can use ggplot2 to create a lot of different visualizations by applying different properties to the data variables.


The read_csv() function is a part of the dplyr package.

A. True

B. False

It is false statement. Explain: The read_csv() function is a part of the readr package. It imports a .CSV file for use in R.

Working with pipes

If you are following along with the video and receiving an error after running line 1, try the following:

  1. After typing the function name data, allow the dropdown menu to pop-up.

ALl4jpWURieJRcGOb9K6Sg_fbb66d26edf44222a6f99b83dbc7b6f1_1 data

  1. Make sure the top function titled "data" is highlighted in blue, and then press ENTER. Two parentheses will be automatically placed after the function, and type the rest of the syntax "Toothgrowth" between the parentheses. Then, click on the RUN button.

  2. Notice that once the data has been loaded into memory, you will see the ToothGrowth item populate into the Data section on the right.

sEebUscCQc6Q5e-wfaAeMg_640612d0aef049d8a12992a9761338f1_2 variable_defined

After the data has been successfully loaded, resume with the rest of the video, and be very careful to double check the syntax structure and placement of characters to avoid errors.

Working with pipes

Questions: A nested function is a function contained within code that performs a broader function.

A. True

B. False

It is true statement. Explain: A nested function is a function contained within code that performs a broader function. The nested function performs its own specific function within the code.

Which of the following operators is the pipe operator?

A. %>%

B. *

C. <-

D. !=

The correct answer is A. %>%. Explain: The pipe operator is %>%. You can use it in R programming to call out a pipe to express a sequence of multiple operations.