What type is 42?
COMPUTING AND DIGITAL LITERACY
This document was made by AI and there may be mistakes. If a question or answer looks wrong, use the Flag a mistake button to let Brett know so he can fix it.
This is how a computer tells a number apart from a word or a yes-or-no answer. Your age is a number it can add, your name is text it can display, and whether you are logged in is a yes or no it can check. Mixing them up breaks a program, like trying to add two names together. Knowing the type tells you what you are allowed to do with a piece of information.
What type is each of these values: 12, 4.50, “Sam”, True?
Solution
The one rule to remember first: the type is decided by what the value looks like, not what it means.
12 is a whole number, so it is an integer. 4.50 has a decimal point, so it is a float.
“Sam” is text in quotes, so it is a string. True is a yes-or-no value, so it is a boolean.
What is 12 + 3, and what is “12” + “3”?
Solution
12 + 3 adds two numbers: 12 + 3 = 15.
“12” + “3” joins two pieces of text: “12” + “3” = “123”.
Check the type before predicting the result: the same symbol does a different job on numbers and on text.
What type is 42?
What type is 3.5?
What type is “hello”?
What type is True?
What is “12” + “3” in most languages?
What is 12 + 3?
Which type holds yes-or-no values?
Is “42” a number or text?
Which type would a price such as 4.99 be?
A program stores a password “3845” and then tries to add 1 to it. What goes wrong?
Your score: 0 / 10
1. Integer
2. Float
3. String
4. Boolean
5. “123” (the texts join)
6. 15
7. Boolean
8. Text (a string)
9. Float
10. It fails: the password is text, so you cannot add a number to it.