Hey, I just picked up python again after not coding with it for many years. But I wanted to throw some simple scripts together to see if I remember all the functionality so far. Now I've got this code:
-
#!/usr/bin/python
-
-
# A program developed to see if the temperature is Celcius or Farhenheit
-
# and than convert it to the other in a more user friendly manner
-
-
import os, sys
-
import math
-
-
def far(temp):
-
-
Celcius = ((temp - 32) * 5) / 9
-
Kelvin = Celcius + 273.15
-
-
def cel(temp):
-
-
Far = (temp * 1.8) + 32
-
Kelvin = temp + 273.15
-
-
def kelvin(temp):
-
-
Celcius = temp + 273.15
-
Far = (Celcius * 1.8) + 32
-
-
-
human = raw_input("Is your temperature in Fahrenheit (f), Celcius (c), or Kelvin (k) --> ")
-
temp1 = int(raw_input("What is your temperature --> ")
-
-
if human=="f":
-
far(temp1)
-
print "Your temperature is %s in Celcius and %s in Kelvin" % Celcius,Kelvin
-
if human=="c":
-
cel(temp1)
-
print "Your temperature is %s in Fahrenheit and %s in Kelvin" % Far,Kelvin
-
if human=="k":
-
kelvin(temp1)
-
print "Your temperature is %s in Celcius and %s in Fahrenheit" % Celcius,Far
-
I want the user to define which kind of temperature they have and than the program to output the other temperatures. But so far all I get is an error in the syntax at line 28:
-
File "temp2.py", line 28
-
if human=="f":
-
^
-
SyntaxError: invalid syntax
-
Anyone have any thoughts?