This course has already ended.

Repository-exercise on branches

Note order

Solve the parts of this exercise in the order 1, 2 and 3.

The round10/git_exercise directory of the remote material repository has a Python script temperature.py that transforms the temperature in Celsius scale to the Fahrenheit scale using an erroneusly formula.

Input temperature: -2
-2.0 C = 30.8 F

Place the script in the round10/git_exercise directory of your personal local repository and manage the script by using Git as decribed below.

Part 1

Create a new branch temp_double_print.

Add functionality to the new branch that calculates the Fahrenheit to Celsius transformation using the same erroneous formula in reverse. Push your changes to the your personal remote directory.

Input temperature: 0
0.0 C = 32.0 F
0.0 F = -53.333333333333336 C
Input temperature: 32
32.0 C = 51.2 F
32.0 F = 0.0 C

About the main branch

Do a new commit, where you have reverted to the old version of temperature.py, if you accidentally altered the main branch: git checkout <commit hash> -- temperature.py, where <commit hash> is the hash of the commit containing the unmodified temperature.py file.

A+ presents the exercise submission form here.


Part 2

Let us assume that we want now to correct the mistake. Fix the formula both in master and temp_double_print branches.

The correct formula is TF = TC × 9 / 5 + 32.

Remember to push the changes in the both branches to the your personal remote directory.

An example of the functioning of the fixed script in the main branch:

Input temperature: 0
0.0 C = 32.0 F

An example of the functioning of the fixed script in the temp_double_print branch:

Input temperature: 0
0.0 C = 32.0 F
0.0 F = -17.77777777777778 C

A+ presents the exercise submission form here.


Part 3

Create a new branch direction_query, where the user can select the direction of the transformation by entering either the "FC" or "CF" string as input. Push your changes to the your personal remote directory.

Select transform direction (CF) or (FC): CF
Input temperature: 23
23.0 C = 73.4 F
Select transform direction (CF) or (FC): FC
Input temperature: 73.4
73.4 F = 23.000000000000004 C

A+ presents the exercise submission form here.

Posting submission...