Intro Python: Converting temperatures from Celsius to Fahrenheit
Автор: Mihai Nan
🌟 Problem: Converting temperatures from Celsius to Fahrenheit
Problem description
The goal is to build a function that converts temperatures from Celsius to Fahrenheit and returns them in a list.
Each temperature is a real number with two decimal places. The conversion formula is:
where:
Cis the temperature in CelsiusFis the corresponding temperature in Fahrenheit
The function must receive a list of temperatures in Celsius and return a list of temperatures in Fahrenheit, with two decimal places.
📘 Input file structure
train.csv
Contains three columns:
SampleID– numeric identifier for each temperaturetemperature_c– temperature in Celsiustemperature_f– temperature in Fahrenheit
Example:
| SampleID | temperature_c | temperature_f |
|---|---|---|
| 1 | 0.0 | 32.0 |
| 2 | 25.0 | 77.0 |
| 3 | 37.5 | 99.5 |
| 4 | 100.0 | 212.0 |
test.csv
Has the same structure as train.csv, but without the temperature_f column.
📤 Submission
The output file (submission.csv) must contain:
SampleID– same as intest.csvtemperature_f– temperature converted to Fahrenheit, rounded to two decimal places
Example:
| SampleID | temperature_f |
|---|---|
| 1 | 32.00 |
| 2 | 77.00 |
| 3 | 99.50 |
| 4 | 212.00 |
⚙️ Evaluation
Evaluation will be based on the correctness of predicted values, meaning exact equality between the predicted value and the real value (from the perspective of the first two decimal places):
where N is the total number of examples.
The final score is expressed as a percentage (0–100).
📊 Note
This problem tests:
- Manipulation of lists and real numbers in Python
- Reading and writing CSV files
- Applying mathematical formulas for data transformation