At Cork's Kent Station, why store 3 passengers and 3.5 metres differently?
You're logging a queue at Cork's Kent Station. You count three passengers and measure the queue at three point five metres. Both values are numbers. What would your app lose if you stored both as whole numbers?
You already know how to store a value in a variable. As the readings come in, store the count in passengers and the measurement in distance. The names tell you what the values mean. Now look at what each value needs to store.
The count can jump from three to four when someone joins. That's discrete data, and three fits in an integer. The queue length can vary between three and four metres. That's continuous data. A float represents a real-valued measurement such as three point five.
You count eight passengers and measure a queue length of six point two metres. Which types should you choose if the count uses a whole-number type and the length keeps its fractional part? Pick the pair with the count first.
With one slash, seven divided by two gives three point five metres per piece. With two slashes, Python rounds the quotient down and gives the integer three. Finally, six divided by two with one slash gives three point zero. Ordinary division still returns a float when the quotient is whole.
Try the two operators with nine and two. What does Python return for nine divided by two with one slash, and what does it return with two slashes? Pick the pair in that order.
You type three point five into a length field. The text has digits, but that doesn't make it a whole-number reading. Read it as a float, then see what converting it to an integer would do: you'd lose half a metre. A float keeps that fraction, though some other decimals are stored approximately.
You record queues B, A and C in that order. Sort the records by passenger count, from fewest to most, and you get A, B, C. Sort by measured length, from shortest to longest, and you get A, C, B. The same records can end up in a different order.
An exam question can ask you to state a suitable data type and justify your choice. For the passenger count, write integer because you count whole people. For queue length, write real, represented by a float in Python, because the measurement can include a fraction of a metre.