Advertisement
simeonshopov

Town

Jan 20th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. class Town:
  2.     def __init__(self, name):
  3.         self.name = name
  4.         self.latitude = None
  5.         self.longitude = None
  6.  
  7.     def set_latitude(self, latitude):
  8.         self.latitude = latitude.replace('\\', '')
  9.  
  10.     def set_longitude(self, longitude):
  11.         self.longitude = longitude.replace('\\', '')
  12.         return longitude
  13.  
  14.     def __repr__(self):
  15.         result = ''
  16.         result += f"Town: {self.name} | Latitude: {self.latitude} | Longitude: {self.longitude}"
  17.         return result
  18.  
  19. town = Town("Sofia")
  20. town.set_latitude("42° 41\' 51.04\" N")
  21. town.set_longitude("23° 19\' 26.94\" E")
  22. print(town)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement