π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 | 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:
- Access each GPA value in the table.
- Add them up.
- 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:
- Initialize
sum
to 0. - Loop through each student in the data set:
- Add the studentβs GPA to
sum
.
- Add the studentβs GPA to
- Divide
sum
by the number of students. - Display the result.
Check Your Understanding
- What is a dataset?
- Give two examples of datasets you encounter in daily life.
- Why is it useful to store data in tables or charts?
- How can loops be used with datasets?
Acknowledgement
Content on this page is adapted from Runestone Academy - Barb Ericson, Beryl Hoffman, Peter Seibel.