2.2 Data Types Flashcards
Data types
When programming, variables should be given appropiate data types
What are the different data types
. Character
. String
. Integer
. Real
. Boolean
Character
A single character such as a letter, number or punctuation symbol
Examples:
T
8
?
String
A sequence of characters, including letters, numbers and punctuation
Examples:
Harry Waters
14:50pm
Ice Age 4
Integer
A whole number
Real
A decimal number
Boolean
An answer that only has two possible values
Examples:
. True / False
. Yes / No
. 0 / 1
Casting
Converting the value of a variable from one data type into another
Python casting
Python automatically assumes an input is a string so the int() command is used to cast an input into an integer.
Other Python casting commands include str() and float()