πŸ““4.2: Data Sets

Table of Contents


πŸ“– This page is a condensed version of CSAwesome Topic 4.2


Data Sets

A data set is a collection of specific pieces of information or data. For example, the following table is a data set that keeps track of information about students. Data can be represented in a diagram by using a chart or table. Here it is shown as a spreadsheet table with columns for the first name, last name, email, and GPA.

Spreadsheet software like Excel and Google Sheets store data in a table and provide functions to manipulate and calculate with the data.

Task: Type in another row of data to the table below on row 4 with your choice of values for the name, email, and GPA.

firstname lastname email GPA
Mickey Mouse mickey@disney.com 3.5
Minnie Mouse minnie@disney.com 4.0
Donald Duck donald@disney.com 3.0
(your row here) Β  Β  Β 

Data sets can be manipulated and analyzed to solve a problem or answer a question. Data in a table or chart can be used to plan the algorithm that will be used to manipulate the data.

For example: How would you find the average GPA of the students in the table above?
You would need to:

  1. Access each GPA value in the table.
  2. Add them up.
  3. Divide by the number of rows.

When analyzing data sets, values within the set are accessed and used one at a time, then processed according to the desired outcome. Loops can be used to access and process each value in a data set.


Practice: Pseudocode for Average GPA

Arrange the steps in the correct order:

  1. Initialize sum to 0.
  2. Loop through each student in the data set:
    • Add the student’s GPA to sum.
  3. Divide sum by the number of students.
  4. Display the result.

Check Your Understanding

  1. What is a dataset?
  2. Give two examples of datasets you encounter in daily life.
  3. Why is it useful to store data in tables or charts?
  4. How can loops be used with datasets?

Acknowledgement

Content on this page is adapted from Runestone Academy - Barb Ericson, Beryl Hoffman, Peter Seibel.