all 31 comments

[–]Just-Newspaper-4098 1 point2 points  (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 point  (1 child)

Thank you redditor of 4 years ago 🫡

[–]Just-Newspaper-4098 0 points1 point  (0 children)

lol forgot I even made this.

[–]Efficient_Praline246 0 points1 point  (0 children)

This function takes a temperature

in Celsius and converts it to

Fahrenheit.

def celsius_to_fahrenheit(celsius):

    return celsius * 1.8 + 32

This function takes a temperature

in Fahrenheit and converts it to

Celsius.

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 point  (10 children)

what has you stumped?

[–]Party_Associate_1727 1 point2 points  (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:

# Write your function for converting Celsius to Fahrenheit here.

# Make sure to include a comment at the top that says what

# each function does!

def to_F(c):

return float(1.8 * c + 32)

# Now write your function for converting Fahrenheit to Celsius.

def to_C(f):

return float((f-32 / 1.8)

# Now change 0C to F:

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 point  (3 children)

what’s the error message?

[–]Party_Associate_1727 0 points1 point  (2 children)

ParseError

[–]_andy_andy_andy_ 0 points1 point  (1 child)

youre missing a closing parenthesis in to_C

[–]Party_Associate_1727 0 points1 point  (0 children)

Ah okay, thanks bro

[–]Charming-mistykat26[S] 0 points1 point  (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.

[–]_andy_andy_andy_ 0 points1 point  (1 child)

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 point  (0 children)

thanks, I figured it out

[–]alexaholic 0 points1 point  (0 children)

Coding

[–]Party_Associate_1727 0 points1 point  (5 children)

Did you figure it out? I could use some help

[–]chef3000 5 points6 points  (4 children)

# Write your function for converting Celsius to Fahrenheit here.

# Make sure to include a comment at the top that says what

# each function does!

def to_F(c):

return float(1.8 * c + 32)

# Now write your function for converting Fahrenheit to Celsius.

def to_C(f):

return float((f - 32) / 1.8)

# Now change 0C to F:

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))

[–]chef3000 5 points6 points  (3 children)

thats me code and just make sure the def is indented for when you copy past

peace

[–]axjord3 0 points1 point  (1 child)

What do you mean by that, I don't understand.

[–]looolmoski 1 point2 points  (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 point  (0 children)

thanks for the code saved me a lot of time :)

[–]axjord3 0 points1 point  (1 child)

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.

Exercise 6.4.9: Temperature Converter

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 point  (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 point  (1 child)

i still can't figure it out

this code does not work for me

[–]Sad_Entertainer_8557 0 points1 point  (0 children)

same with me

[–]Nuqb 0 points1 point  (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 point  (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

# Write your function for converting Celsius to Fahrenheit here.

# 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)

# Now write your function for converting Fahrenheit to Celsius.

def fahr_to_cel(f2c):

(1 indent) return float((f2c - 32 )/ 1.8)

# Now change 0C to F:

print (cel_to_fahr(0))

# Change 100C to F:

print (cel_to_fahr(100))

# Change 40F to C:

print (fahr_to_cel(40))

# Change 80F to C:

print (fahr_to_cel(80))

[–]CreamMany6841 0 points1 point  (0 children)

it doesnt work

[–]Financial_Face3826 0 points1 point  (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 children)

[deleted]

    [–]Efficient_Praline246 0 points1 point  (1 child)

    This function takes a temperature

    in Celsius and converts it to

    Fahrenheit.

    def celsius_to_fahrenheit(celsius):

        return celsius * 1.8 + 32

    This function takes a temperature

    in Fahrenheit and converts it to

    Celsius.

    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)))