Core programming fundamentals · Lesson 4 of 60 · Code lesson, JavaScript or Python · Optional
Data types
A data type says what kind of value you have: a whole number, a decimal number, text, true or false, or nothing at all (null).
The type decides what you can do with a value, because adding numbers works differently from joining text.
Some languages check types before running (static typing), while JavaScript and Python check while running (dynamic typing).
Worked example
In JavaScript, null means "no value" on purpose, and whole numbers and decimals share one number type.
const name = "Ada";
const age = 12;
const height = 1.5;
const isStudent = false;
const nickname = null;
console.log(name, age, height, isStudent, nickname);Output: Ada 12 1.5 false null
In Python, None means "no value" on purpose, and whole numbers (int) and decimals (float) are separate types.
name = "Ada"
age = 12
height = 1.5
is_student = False
nickname = None
print(name, age, height, is_student, nickname)Output: Ada 12 1.5 False None
Your turn
The last value, nickname, holds nothing yet. Give it the text "Adi" so the last thing printed is Adi.
Expected output: Ada 12 1.5 false Adi
Loading your practice…
Preparing your workspace…