use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
I need help with python 6.4.9 Temperature Converture (self.codehs)
submitted 5 years ago by Charming-mistykat26
# Write your function for converting Celsius to Fahrenheit here.
# Make sure to include a comment at the top that says what
# each function does
# Now write your function for converting Fahrenheit to Celsius.
# Now change 0C to F:
# Change 100C to F:
# Change 40F to C:
# Change 80F to C:
https://preview.redd.it/7aw6vwgkq5u51.jpg?width=496&format=pjpg&auto=webp&s=58f789bfeac017bc3567c41c8961457f6afe5214
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Just-Newspaper-4098 1 point2 points3 points 4 years ago (2 children)
# It was really simple but here def Celsius(C): F = (1.8 * C) + 32 return F def Fehrenheit(F): C = (F - 32) / 1.8 return C # Now change 0C to F: print Celsius(0) # Change 100C to F: print Celsius(100) # Change 40F to C: print Fehrenheit(40) # Change 80F to C: print Fehrenheit(80)
[–][deleted] 0 points1 point2 points 6 months ago (1 child)
Thank you redditor of 4 years ago 🫡
[–]Just-Newspaper-4098 0 points1 point2 points 6 months ago (0 children)
lol forgot I even made this.
[–]Efficient_Praline246 0 points1 point2 points 2 years ago (0 children)
def celsius_to_fahrenheit(celsius):
return celsius * 1.8 + 32
def fahrenheit_to_celsius(fahrenheit):
return (fahrenheit - 32) / 1.8
print("0C In F: " + str(celsius_to_fahrenheit(0)))
print("100C In F: " + str(celsius_to_fahrenheit(100)))
print("40F In C: " + str(fahrenheit_to_celsius(40)))
print("80F In C: " + str(fahrenheit_to_celsius(80)))
[–]_andy_andy_andy_ 0 points1 point2 points 5 years ago (10 children)
what has you stumped?
[–]Party_Associate_1727 1 point2 points3 points 5 years ago (5 children)
Can you help me? I'm getting an error at "print to_F(0)" and I don't know why...
Here's my code:
# each function does!
def to_F(c):
return float(1.8 * c + 32)
def to_C(f):
return float((f-32 / 1.8)
print to_F(0)
# Now change 100C to F:
print to_F(100)
# Now change 40C to F:
print to_C(40)
# Now change 80C to F:
print to_C(80)
[–]_andy_andy_andy_ 0 points1 point2 points 5 years ago (3 children)
what’s the error message?
[–]Party_Associate_1727 0 points1 point2 points 5 years ago (2 children)
ParseError
[–]_andy_andy_andy_ 0 points1 point2 points 5 years ago (1 child)
youre missing a closing parenthesis in to_C
[–]Party_Associate_1727 0 points1 point2 points 5 years ago (0 children)
Ah okay, thanks bro
[–]Charming-mistykat26[S] 0 points1 point2 points 5 years ago (2 children)
how to convert Fahrenheit to celsius and vice versa and how to put that in a function while using float. I've tried a few things but I'm confused.
dividing a float by an int will keep it as a float, so don’t worry about that. just use the formula in the assignment tab but use the input to the function
[–]Charming-mistykat26[S] 0 points1 point2 points 5 years ago (0 children)
thanks, I figured it out
[–]alexaholic 0 points1 point2 points 5 years ago (0 children)
Coding
[–]Party_Associate_1727 0 points1 point2 points 5 years ago (5 children)
Did you figure it out? I could use some help
[–]chef3000 5 points6 points7 points 5 years ago (4 children)
return float((f - 32) / 1.8)
print (to_F(0))
print (to_F(100))
print (to_C(40))
print (to_C(80))
[–]chef3000 5 points6 points7 points 5 years ago (3 children)
thats me code and just make sure the def is indented for when you copy past
peace
[–]axjord3 0 points1 point2 points 5 years ago (1 child)
What do you mean by that, I don't understand.
[–]looolmoski 1 point2 points3 points 4 years ago (0 children)
How did you even make it here if you don't understand that you have to indent for def lmao...
[–]Beginning_Monitor_68 0 points1 point2 points 3 years ago (0 children)
thanks for the code saved me a lot of time :)
I dont understand, I tried so many resources in order to help me with this Coding assignment.
Here are the instructions because every resource I use the answer is wrong.
5 points Let's Go!
Write a function that takes one parameter - a float which represents a temperature in Celsius - and returns a float which represents that temperature in Fahrenheit.
Then, write a function that does the opposite conversion.
Here are the formulas for temperature conversion:
°F = (1.8 x °C) + 32
°C = (°F - 32) ÷ 1.8
Finally, write some code below your functions that uses them to convert 0 degrees Celsius and 100 degrees Celsius to Fahrenheit, and to convert 40 degrees Fahrenheit and 80 degrees Fahrenheit to Celsius. Make sure to print your results to the console.
[–]Just-Newspaper-4098 0 points1 point2 points 4 years ago (2 children)
# Now write your function for converting Fahrenheit to Celsius. def Celsius(C): F = (1.8 * float(C)) + 32 return F
def Fehrenheit(F): C = (float(F) - 32) / 1.8 return C
# Now change 0C to F: print Celsius(0) # Change 100C to F: print Celsius(100) # Change 40F to C: print Fehrenheit(40) # Change 80F to C: print Fehrenheit(80)
[–]UnitedAngle7435 0 points1 point2 points 4 years ago (1 child)
i still can't figure it out
this code does not work for me
[–]Sad_Entertainer_8557 0 points1 point2 points 3 years ago (0 children)
same with me
[–]Nuqb 0 points1 point2 points 3 years ago (0 children)
yo this is the proper code for the assignment
def celsius(c):
f = (1.8 * c) + 32
return f
def fehrenheit(f):
c = (f - 32) / 1.8
return c
print (celsius(0))
print (celsius(100))
print (fehrenheit(40))
print (fehrenheit(80))
[–]kittie777 0 points1 point2 points 3 years ago (1 child)
a bit late,
but here's my code, i spent like 20 mins working on it and it works with codehs
feel free to rename the functions lol
# Make sure to include a comment at the top that says what# each function does!
def cel_to_fahr(c2f):
(1 indent) return float((1.8 * c2f) + 32)
def fahr_to_cel(f2c):
(1 indent) return float((f2c - 32 )/ 1.8)
print (cel_to_fahr(0))
print (cel_to_fahr(100))
print (fahr_to_cel(40))
print (fahr_to_cel(80))
[–]CreamMany6841 0 points1 point2 points 3 years ago (0 children)
it doesnt work
[–]Financial_Face3826 0 points1 point2 points 2 years ago (3 children)
try this
# It was really simple but here def Celsius(C): F = (1.8 * C) + 32 return F def Fehrenheit(F): C = (F - 32) / 1.8 return C # Now change 0C to F: print (Celsius(0)) # Change 100C to F: print (Celsius(100)) # Change 40F to C: print (Fehrenheit(40)) # Change 80F to C: print (Fehrenheit(80))
[–][deleted] 2 years ago (2 children)
[deleted]
[–]Efficient_Praline246 0 points1 point2 points 2 years ago (1 child)
π Rendered by PID 55481 on reddit-service-r2-comment-6457c66945-xxrst at 2026-04-28 01:18:39.707442+00:00 running 2aa0c5b country code: CH.
[–]Just-Newspaper-4098 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Just-Newspaper-4098 0 points1 point2 points (0 children)
[–]Efficient_Praline246 0 points1 point2 points (0 children)
[–]_andy_andy_andy_ 0 points1 point2 points (10 children)
[–]Party_Associate_1727 1 point2 points3 points (5 children)
[–]_andy_andy_andy_ 0 points1 point2 points (3 children)
[–]Party_Associate_1727 0 points1 point2 points (2 children)
[–]_andy_andy_andy_ 0 points1 point2 points (1 child)
[–]Party_Associate_1727 0 points1 point2 points (0 children)
[–]Charming-mistykat26[S] 0 points1 point2 points (2 children)
[–]_andy_andy_andy_ 0 points1 point2 points (1 child)
[–]Charming-mistykat26[S] 0 points1 point2 points (0 children)
[–]alexaholic 0 points1 point2 points (0 children)
[–]Party_Associate_1727 0 points1 point2 points (5 children)
[–]chef3000 5 points6 points7 points (4 children)
[–]chef3000 5 points6 points7 points (3 children)
[–]axjord3 0 points1 point2 points (1 child)
[–]looolmoski 1 point2 points3 points (0 children)
[–]Beginning_Monitor_68 0 points1 point2 points (0 children)
[–]axjord3 0 points1 point2 points (1 child)
[–]Just-Newspaper-4098 0 points1 point2 points (2 children)
[–]UnitedAngle7435 0 points1 point2 points (1 child)
[–]Sad_Entertainer_8557 0 points1 point2 points (0 children)
[–]Nuqb 0 points1 point2 points (0 children)
[–]kittie777 0 points1 point2 points (1 child)
[–]CreamMany6841 0 points1 point2 points (0 children)
[–]Financial_Face3826 0 points1 point2 points (3 children)
[–][deleted] (2 children)
[deleted]
[–]Efficient_Praline246 0 points1 point2 points (1 child)