Programming Basics - Data Types and Operators Flashcards
How many main data types are there?
5
What is an integer (int)?
Whole numbers only e.g. 8,0,-567,6482
What is a real/float (real)?
Numbers that have a decimal part. e.g. 0.15, -2.67, 100.0
What is a boolean (bool)?
Can only take one of two values, usually TRUE or FALSE.
What is a character (char)?
A single letter, number, symbol. e.g. “£”,”7”,”a”
What is a string (str)?
Used to represent text, is a collection of characters. e.g. “Ftsd4” or “876££”
What does using correct data types do to code?
Makes code more memory efficient, robust and predictable.
Each data type has different amounts of memory. What are they?
Integer: 2 or 4 bytes
Real: 4 or 8 bytes
Boolean: 1 bit needed but 1 byte normally used
Character: 1 byte
String: 1 byte for every character in the string
What will weakly typed languages do?
Try convert data types to avoid errors, but can lead to unpredictable results.
What will strongly typed languages do?
Won’t try convert data types so will produce more errors but more predictable results.
What is casting?
Langages have functions that let you manually convert between data types. This is known as casting.