Time 1.3 hrs
Authors Sandra Kuipers
Minimum Year Group None
Data comes in many forms: numbers, letters, symbols, and more. This unit looks at primitive data types and how they make up the building blocks of all programming languages.
This work is shared under the following license: Creative Commons BY-SA-NC
What was successful? What needs changing? Alternative Assessments and Lesson Ideas? What other Differentiation Ideas/Plans could be used?
Any CC attribution, thanks, credit, etc.
This page requires you to be logged in to access it. Please login and try again.
What is Data?
- A computer stores information as data.
- A bindary digit (bit) is the smallest form of data.
- Binary can be used to store 1s and 0s.
- All other types of data start with binary, and are converted into something more meaningful:
Types of Data
- The variables in our code can store many different types of data.
- Chances are, you've already seen and used some data types in your code.
- Some programming languages are loosely typed:
- This means they don't require you to declare a type upfront.
- For example, a
- We can also combine different types without creating an error.
"Hello Cat" + 5;will create the string
- Some programming languages are strictly typed:
- This means each variable must be declared with its data type.
- For example, in C#, a
string myVar;can only hold data that is a string.
- Combining variables with different types generally creates an error.
- The following are some of the most common types of data.
True and False
The boolean type has only two values:
This type is commonly used to store yes/no values:
truemeans “yes, correct”, and
falsemeans “no, incorrect”.
var thisThing = true; var thatThing = false;
- We’ll cover booleans more deeply in the unit on Logical operators.
It helps to remember booleans as a switch: they can only be on or off (true or false)
An integer is a type of number that does not have a decimal point.
A whole number, including negative numbers.
var x = 10; var y = -36;
- There are many operations we can do with numbers, such as multiplication
-, and so on.
var score = 42 + 500;
Numbers with Decimals
- A float (or floating point number) is a type of number that has a decimal point.
var distance = 4.5; var hours = 1.125;
- To remember Floats vs Integers, I think of them floating on their decimal point like a life-preserver.
Letters and Symbols
- A string is any number of words, letters and symbols surrounded by quotes:
var question = "What day is it?"; var answer = "Monday";
- Strings can use either 'single quotes' or "double quotes"
var answer1 = "Abolsutely"; var answer2 = 'Not sure'; var answer3 = "It's alright";
It helps to think of them as a bunch of letters, connected on a string:
- Often we need to store a list of things.
- An array is a special variable, which can hold more than one value at a time.
var cars = ["Volvo", "BMW", "Tesla"]; var fibonacci = [0, 1, 1, 2, 3, 5, 8, 13];
- Spaces and line breaks are not important. A declaration can span multiple lines:
var fruit = [ "Apple", "Pear", "Kiwi" ];
- We’ll cover these more in the unit on Arrays.
- There's many more types of data.
- The data types here are often called primitive types.
- This is because they're the basic building-blocks of more complex data.
- Other types of data, like objects, are made up of primitive types.
Digital Scavenger Hunt
- Take a moment to consider how the above data types might exist in the world around you.
- Your goal is to search for images to help visualize these different data types.
- You may search the web for images.
- You are also welcome to grab your phone and search the school.
- The pictures in this unit are examples, please don't copy them :)
- Open up your Google slides from the Computer Science unit.
- Add one slide called Data:
- Include a short definition, in your own words.
- At least one link to a website or video that helps explain this concept.
- Then, add one slide for each of the following data types:
- For each slide, add:
- A short definition, in your own words.
- An image to help illustrate this concept.
- Once you have finished, submit the link to your slideshow as evidence of learning in this unit.
There are no records to display.