Fahrenheit to Celsius Conversion

PythonPythonBeginner
Practice Now

This tutorial is from open-source community. Access the source code

Introduction

In many countries, temperature is measured in Celsius. However, in some countries, temperature is measured in Fahrenheit. It is important to be able to convert between these two units of measurement. In this challenge, you will write a function that converts Fahrenheit to Celsius.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL python(("`Python`")) -.-> python/BasicConceptsGroup(["`Basic Concepts`"]) python(("`Python`")) -.-> python/FunctionsGroup(["`Functions`"]) python/BasicConceptsGroup -.-> python/comments("`Comments`") python/FunctionsGroup -.-> python/function_definition("`Function Definition`") subgraph Lab Skills python/comments -.-> lab-13629{{"`Fahrenheit to Celsius Conversion`"}} python/function_definition -.-> lab-13629{{"`Fahrenheit to Celsius Conversion`"}} end

Fahrenheit to Celsius Conversion

Write a function fahrenheit_to_celsius(degrees) that takes a temperature in Fahrenheit as a parameter and returns the temperature in Celsius. The function should follow the conversion formula C = (F - 32) * 5 / 9, where C is the temperature in Celsius and F is the temperature in Fahrenheit.

def fahrenheit_to_celsius(degrees):
  return ((degrees - 32) * 5 / 9)
fahrenheit_to_celsius(77) ## 25.0

Summary

In this challenge, you have written a function that converts Fahrenheit to Celsius. This is an important skill to have when working with temperature data in different units of measurement.

Other Python Tutorials you may like