Question #3

Multiple Choice

The formula to convert Fahrenheit (F) temperature to Celsius (C) is [tex]C=\frac{F-32}{1.8}[/tex]. Which line of code will accomplish this conversion?

A. celsius [tex]$=$[/tex] Fahrenheit [tex]$-32 / 1.8$[/tex]

B. celsius [tex]$=($[/tex] fahrenheit [tex]$-32) / 1.8$[/tex]

C. celsius [tex]$=$[/tex] Fahrenheit [tex]$- 32 / 1.8$[/tex]

D. celsius [tex]$=($[/tex] Fahrenheit [tex]$-32) * 1.8$[/tex]

Answer :

To convert a temperature from Fahrenheit to Celsius, we use the formula:

[tex]\[ C = \frac{F - 32}{1.8} \][/tex]

Let's examine the multiple-choice options to determine which one matches this formula:

1. celsius = Fahrenheit - 32 / 1.8

This option doesn't correctly use parentheses, and it also includes an erroneous syntax with "/ ". It doesn't represent the formula correctly.

2. celsius = (fahrenheit - 32) / 1.8

This option correctly uses parentheses around "fahrenheit - 32" and divides by 1.8, matching the formula exactly.

3. celsius = Fahrenheit - 32 1.8

This option does not correctly calculate the result because it will multiply 32 by 1.8 before subtracting from Fahrenheit, which is not correct according to the formula.

4. celsius = (Fahrenheit - 32) 1.8

This option multiplies after subtracting, which contradicts the division needed in the conversion formula.

From these explanations, option 2 is the correct choice, as it accurately represents the formula to convert Fahrenheit to Celsius.