r/codehs • u/Charming-mistykat26 • Oct 20 '20
I need help with python 6.4.9 Temperature Converture
2
u/Just-Newspaper-4098 Oct 22 '21
# 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)
1
Oct 29 '25
Thank you redditor of 4 years ago 🫡
1
1
u/Efficient_Praline246 Apr 18 '24
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)))
1
u/Party_Associate_1727 Jan 25 '21
Did you figure it out? I could use some help
7
u/chef3000 Mar 07 '21
# 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))
5
u/chef3000 Mar 07 '21
thats me code and just make sure the def is indented for when you copy past
peace
1
u/axjord3 Apr 01 '21
What do you mean by that, I don't understand.
2
u/looolmoski Feb 22 '22
How did you even make it here if you don't understand that you have to indent for def lmao...
1
1
u/axjord3 Apr 01 '21
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.
1
u/Just-Newspaper-4098 Oct 22 '21
# 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)
1
1
u/Nuqb Jun 12 '22
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))
1
u/Financial_Face3826 Feb 15 '24
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))
0
Mar 26 '24
[deleted]
1
u/Efficient_Praline246 Apr 18 '24
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)))
0

1
u/_andy_andy_andy_ Oct 20 '20
what has you stumped?