Comprehensive and Detailed Explanation From Exact Extract:
Miles per gallon (MPG) is calculated as miles traveled divided by gallons consumed, typically resulting in a decimal value (e.g., 25.5 MPG). According to foundational programming principles, MPG should be a variable (as it is computed and may change) and a floating-point type to handle decimals.
Option A: "Variable float milesTraveled." This is incorrect. While miles traveled may be a float variable, the question asks for the declaration of MPG, not miles traveled.
Option B: "Constant float milesPerGallon." This is incorrect. MPG is calculated and may vary with different inputs, so it should be a variable, not a constant (const).
Option C: "Constant float milesTraveled." This is incorrect. The question focuses on MPG, not miles traveled, and constants are inappropriate for computed values.
Option D: "Variable float milesPerGallon." This is correct. MPG requires a float to store decimal values (e.g., 22.7) and a variable to allow updates based on new calculations. For example, in C: float milesPerGallon = miles / gallons;.
Certiport Scripting and Programming Foundations Study Guide (Section on Variables and Data Types).
Python Documentation: “Floating Point Arithmetic” (https://docs.python.org/3/tutorial/floatingpoint.html).
W3Schools: “C Data Types” (https://www.w3schools.com/c/c_data_types.php).