Data types - Programming - AQA - GCSE Computer Science Revision - AQA - BBC Bitesize (2024)

Table of Contents
Data types Casting

Data types

Each has a data type. The data type determines what type of value the variable will hold.

Data typePurposeExample
IntegerWhole numbers27
RealDecimal numbers27.5
CharacterA single alphanumeric characterA
StringOne or more alphanumeric charactersABC
BooleanTRUE/FALSE TRUE
Data typeInteger
PurposeWhole numbers
Example27
Data typeReal
PurposeDecimal numbers
Example27.5
Data typeCharacter
PurposeA single alphanumeric character
ExampleA
Data typeString
PurposeOne or more alphanumeric characters
ExampleABC
Data typeBoolean
PurposeTRUE/FALSE
ExampleTRUE

Different data types have limitations:

  • integers and real numbers cannot be concatenated, ie joined together.
  • numbers held in strings cannot be subject to mathematical operations.

Casting

Sometimes a programmer needs to change the data type of the contents of a variable. For example, an integer may need to be converted to a string in order to be displayed as part of a message. This process is known as casting. The following examples in Python convert a string to an integer and an integer to a string:

str(68) returns “68”int(“54”) returns 54
Data types - Programming - AQA - GCSE Computer Science Revision - AQA - BBC Bitesize (2024)
Top Articles
Latest Posts
Article information

Author: Roderick King

Last Updated:

Views: 5766

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Roderick King

Birthday: 1997-10-09

Address: 3782 Madge Knoll, East Dudley, MA 63913

Phone: +2521695290067

Job: Customer Sales Coordinator

Hobby: Gunsmithing, Embroidery, Parkour, Kitesurfing, Rock climbing, Sand art, Beekeeping

Introduction: My name is Roderick King, I am a cute, splendid, excited, perfect, gentle, funny, vivacious person who loves writing and wants to share my knowledge and understanding with you.