A variable should hold a person's height in meters. Which data type should the variable be?

Study for the WGU C173 Scripting and Programming Test. Dive into coding challenges and multiple-choice questions with expert explanations. Prepare thoroughly and excel!

The appropriate data type for storing a person's height in meters is a float. This is because height is a continuous numerical value that can include decimal places; for example, a person might be 1.75 meters tall. A float allows for the representation of such values, accommodating fractions which are essential when dealing with measurements.

In contrast, an integer would limit the variable to whole numbers, making it unsuitable for capturing the precise height of an individual, especially since height usually involves decimal values. A string would be inappropriate as it is meant for textual data, not numerical values. Lastly, a boolean represents true or false values, which does not apply to numeric measurements like height. Thus, using a float is the most logical choice for accurately representing height in meters.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy