Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. #def compareStrings(x,y):
  2. #   if len(x) != len(y):
  3. #       return max(x,y,key=len), "är störst!"
  4. #   else:
  5. #       return "Lika stora!"
  6. #def compareInt(x,y):
  7. #   if x != y:
  8. #       return max(x,y)+ " är störst!"
  9. #   else:
  10. #       return "Lika stora!"
  11.  
  12. #def uppgift13(x,y):
  13. #   if x.isnumeric() == False and x.isnumeric() == False:
  14. #       return compareStrings(x,y)
  15. #   elif x.isnumeric() and y.isnumeric():
  16. #       return compareInt(float(x),float(y))
  17. #   else:
  18. #       return "Går inte att jämföra "+x+" med "+y
  19. #
  20. #x = input("Skriv in x: ")
  21. #y = input("Skriv in y: ")
  22. #print (uppgift13(x,y))
  23.  
  24. def uppgift14(temp):
  25.     args = temp.split()
  26.     sort = args[2]
  27.     start = int(args[0])
  28.     stop = int(args[1])
  29.    
  30.     if sort.upper() == "F":
  31.         toSort = "C"
  32.     else:
  33.         toSort = "F"
  34.  
  35.     temp_dict = {
  36.             "F":lambda farenheit: (farenheit-32)*(5/9),
  37.             "C":lambda celcius:  celcius*((9/5) + 32)
  38.             }
  39.     for x in range(start, stop,10):
  40.         print (x, sort,"=",temp_dict[args[2].upper()](x),toSort )
  41.  
  42. test = input("Skriv in exempel 100 200 F ")
  43. uppgift14(test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement