Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Khofo temp converter
- # -*- coding: utf-8 -*-
- #Functions
- def convert():
- print "Welcome tp khofo's temperature converter"
- while True:
- try:
- temp = int(raw_input("Please choose 1. Celsius to Fahrenheit, or 2. Fahrenheit to Celsius: "))
- if temp == 1:
- cel = float(raw_input("Please enter the temperature in Celsius u wish to convert: "))
- break
- elif temp == 2:
- fah = float(raw_input("Please enter the temperature in Fahrenheit u wish to convert: "))
- break
- else:
- print "Error: Please retry"
- except:
- print "Error: Please retry"
- if temp == 1:
- converted_fah = (cel*float(9/5))+32
- print ("%d C In fahrenheit is: %d F") % (cel, converted_fah)
- elif temp == 2:
- converted_cel = float(fah-32)*float(5/9)
- print ("%d F in Celsius is: %d C") % (fah, converted_cel)
- def _end_():
- print "Thank you for"
- retry = raw_input("To restart type 'restart' to exit press anything: ")
- if retry == "restart":
- convert()
- else:
- print "Bye"
- def main():
- convert()
- _end_()
- #End of Functions
- #######################################
- print main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement