131.2 Data types and type casting
Learn how different data types represent information in programs, and how to convert between them safely and effectively.
What is a data type?
Declaring variables with different data types
SET age TO 17
SET height TO 1.72
SET name TO "Ella"
SET is_admin TO FALSEage = 17 # Integer
height = 1.72 # Float
name = "Ella" # String
is_admin = False # BooleanType casting
SET age TO "17"
SET age TO INTEGER(age)
SET score TO 3.9
SET score TO INTEGER(score)
SET is_ready TO STRING(TRUE)age = "17"
age = int(age) # Convert string to integer
score = 3.9
score = int(score) # Converts to 3, drops decimal part
is_ready = str(True) # Converts Boolean to string: "True"Concatenating strings and numbers
Using type() to check data types (Python only)
type() to check data types (Python only)Key concepts
Last updated
Was this helpful?