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 = Fahrenheit - 32 / 1.8
B. celsius = (fahrenheit - 32) / 1.8
C. celsius = (Fahrenheit - 32)
1.8
D. celsius = Fahrenheit - 32 * 1.8



Answer :

To determine which line of code correctly converts Fahrenheit (F) to Celsius (C) using the formula [tex]\( C = \frac{F - 32}{1.8} \)[/tex], let's analyze each option step-by-step.

### Option 1:
[tex]\[ \text{celsius} = \text{Fahrenheit} - 32 / 1.8 \][/tex]

- This line of code contains a syntax error with the '/
' operation, making it invalid.

### Option 2:
[tex]\[ \text{celsius} = (\text{fahrenheit} - 32) / 1.8 \][/tex]

- In this line, subtraction is performed first: [tex]\(\text{fahrenheit} - 32\)[/tex].
- The result of the subtraction is then divided by 1.8, which precisely matches the formula [tex]\( C = \frac{F - 32}{1.8} \)[/tex].

### Option 3:
[tex]\[ \text{celsius} = (\text{Fahrenheit} - 32) 1.8 \][/tex]

- Here, the subtraction [tex]\(\text{Fahrenheit} - 32\)[/tex] is done correctly.
- However, the result is then incorrectly multiplied by 1.8 instead of being divided, which does not match our formula.

### Option 4:
[tex]\[ \text{celsius} = \text{Fahrenheit} - 32
1.8 \][/tex]

- In this line, the multiplication is done first because it has higher precedence: [tex]\(32 * 1.8\)[/tex].
- The result of the multiplication is then subtracted from [tex]\(\text{Fahrenheit}\)[/tex], which deviates from our formula.

### Conclusion:
The correct formula for converting Fahrenheit to Celsius is [tex]\( C = \frac{F - 32}{1.8} \)[/tex], and from our analysis, only Option 2 aligns correctly with this formula. Therefore, the line of code that accomplishes this conversion is:

[tex]\[ \text{celsius} = (\text{fahrenheit} - 32) / 1.8 \][/tex]

Thus, the correct index is:

[tex]\[ 2 \][/tex]