Convert Celsius to Fahrenheit

PythonPythonBeginner
Practice Now

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

Introduction

In the field of science, temperature is often measured in Celsius or Fahrenheit. Celsius is the metric unit of temperature measurement, while Fahrenheit is the imperial unit of temperature measurement. Sometimes, it is necessary to convert Celsius to Fahrenheit or vice versa. In this challenge, you will be tasked to convert Celsius to Fahrenheit using a conversion formula.


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-13598{{"`Convert Celsius to Fahrenheit`"}} python/function_definition -.-> lab-13598{{"`Convert Celsius to Fahrenheit`"}} end

Celsius to Fahrenheit

Write a function celsius_to_fahrenheit that takes a temperature in Celsius as an argument and returns the temperature in Fahrenheit. Use the conversion formula F = 1.8 * C + 32 to convert Celsius to Fahrenheit.

def celsius_to_fahrenheit(degrees):
  return ((degrees * 1.8) + 32)
celsius_to_fahrenheit(180) ## 356.0

Summary

In this challenge, you have learned how to convert Celsius to Fahrenheit using a conversion formula. You can now use this knowledge to convert temperatures from Celsius to Fahrenheit in your future projects.

Other Python Tutorials you may like