2.1.12
Data Types
Data Types
Data Types
Every piece of data that is stored has a type. The type determines how it is stored and what you can do with the data.


Integer
Integer
- Whole numbers.
- Examples:
- 12, 0, -142.


Float / Real
Float / Real
- Fractional numbers.
- Examples:
- 0.42, 1.00.


String
String
- Text data.
- Example:
- "Hello, world!".


Character
Character
- A single letter of text data.
- Example:
- 'a'.


Boolean
Boolean
- A True or False value.
- Examples:
- True.
- False.
Casting
Casting
Casting is the process of converting data from one type to another.


Reasons for casting
Reasons for casting
- One of the most common reasons for casting is output.
- Output must be formatted as a string, and so we may need to convert a certain piece of data to a string.
- All input also comes as a string, and must then be converted to other data types.


Casting functions
Casting functions
- Casting to a string can be done using the str function. E.g:
- str(3) gives "3".
- Casting to an integer can be done using the int function. E.g:
- int(3.4) gives 3.
- Casting to a float can be done using the float function. E.g:
- float("3.4") gives 3.4.
1Computational Thinking & Algorithms
1.1Computational Thinking
1.2Algorithms
1.2.1Algorithms
1.2.2Pseudocode
1.2.3Flow Diagrams
1.2.4Logical Reasoning & Debugging
1.2.5Reading Algorithms
1.2.6Correcting Algorithms
1.2.7Complete the Algorithm
1.2.8Search Algorithms
1.2.9Linear Search
1.2.10Binary Search
1.2.11Sort Algorithms
1.2.12Bubble Sort
1.2.13Insertion Sort
1.2.14End of Topic Test - Algorithms
2Programming
2.1Programming Fundamentals
2.1.1Variables & Constants
2.1.2Comments
2.1.3Input & Output
2.1.4Arithmetic Operators
2.1.5Relational Operators
2.1.6Boolean Operators
2.1.7Sequence
2.1.8Selection
2.1.9Iteration
2.1.10Subroutines
2.1.11Scope
2.1.12Data Types
2.1.13Casting
2.1.14Arrays
2.1.152D Arrays
2.1.16Lists
2.1.172D Lists
2.1.18Strings
2.1.19Syntax Errors
2.1.20Logic Errors
2.1.21Runtime Errors
2.1.22End of Topic Test - Programming
2.2Designing Code
3Hardware & Software
3.1Hardware
3.2Software
4Data
5The Internet
6Online Safety & Security
6.1Protecting Yourself Online
Jump to other topics
1Computational Thinking & Algorithms
1.1Computational Thinking
1.2Algorithms
1.2.1Algorithms
1.2.2Pseudocode
1.2.3Flow Diagrams
1.2.4Logical Reasoning & Debugging
1.2.5Reading Algorithms
1.2.6Correcting Algorithms
1.2.7Complete the Algorithm
1.2.8Search Algorithms
1.2.9Linear Search
1.2.10Binary Search
1.2.11Sort Algorithms
1.2.12Bubble Sort
1.2.13Insertion Sort
1.2.14End of Topic Test - Algorithms
2Programming
2.1Programming Fundamentals
2.1.1Variables & Constants
2.1.2Comments
2.1.3Input & Output
2.1.4Arithmetic Operators
2.1.5Relational Operators
2.1.6Boolean Operators
2.1.7Sequence
2.1.8Selection
2.1.9Iteration
2.1.10Subroutines
2.1.11Scope
2.1.12Data Types
2.1.13Casting
2.1.14Arrays
2.1.152D Arrays
2.1.16Lists
2.1.172D Lists
2.1.18Strings
2.1.19Syntax Errors
2.1.20Logic Errors
2.1.21Runtime Errors
2.1.22End of Topic Test - Programming
2.2Designing Code
3Hardware & Software
3.1Hardware
3.2Software
4Data
5The Internet
6Online Safety & Security
6.1Protecting Yourself Online

Unlock your full potential with GoStudent tutoring
Affordable 1:1 tutoring from the comfort of your home
Tutors are matched to your specific learning needs
30+ school subjects covered