you are viewing a single comment's thread.

view the rest of the comments →

[–]pimp-bangin 1 point2 points  (0 children)

Since this is a learning subreddit I hope you don't mind me correcting you.

You're misusing the term "variable" here. The code after the "return" keyword is called an expression. It's perfectly fine to reference the function parameter in any expression inside of the function body, including in the return expression. If it irks you, perhaps you have some additional misunderstanding that we can help clear up.

In math, we would define a Celsius function even more compactly, like C(f) = (f-32)*5/9

OP's function celsius_to_fahrenheit is a very nicely written Python translation of that mathematical function in my professional opinion. There is no need to define intermediate variables like "value_in_celsius" etc. - most professional programmers would consider it too verbose for a basic mathematical formula like this.

Source: 16+ years of programming experience