knowt logo

Data Types

Data types are a way of classifying different data

The data type determines what operations can be conducted on the data and how it is stored.

Integer - whole number - e.g. 30

Real/Float - number with a fractional part (decimal place) - e.g. 25.5

Boolean - two possible values: true or false - e.g. false

String - a set of characters which can include spaces and numbers that are treated as text - e.g. 'the computer'

Character (*doesn't exist in Python*) - a single letter, symbol, number or space - e.g. 'm'

Casting

Changing the data type of a variable is called casting.

Casting functions:

  • str() - changes variable into a string

  • int() - changes variable into an integer

  • float() - changes variable into a float

  • bool() - changes variable into a Boolean

IL

Data Types

Data types are a way of classifying different data

The data type determines what operations can be conducted on the data and how it is stored.

Integer - whole number - e.g. 30

Real/Float - number with a fractional part (decimal place) - e.g. 25.5

Boolean - two possible values: true or false - e.g. false

String - a set of characters which can include spaces and numbers that are treated as text - e.g. 'the computer'

Character (*doesn't exist in Python*) - a single letter, symbol, number or space - e.g. 'm'

Casting

Changing the data type of a variable is called casting.

Casting functions:

  • str() - changes variable into a string

  • int() - changes variable into an integer

  • float() - changes variable into a float

  • bool() - changes variable into a Boolean

robot