Develop a Python program that simulates a weather forecasting service . The program should allow users to
Question:
Develop a Python program that simulates a weather forecasting service. The program should allow users to perform the following operations:
- Set Location: Users can set their current location by providing city and country names.
- Get Weather Forecast: Users can retrieve a weather forecast for the next 7 days, including temperature, precipitation, and wind speed.
- Change Units: Users can change the units of measurement for temperature (Celsius or Fahrenheit) and wind speed (km/h or mph).
- Save Forecast: Users can save the forecast details to a file for later reference.
- Display Forecast: Display the weather forecast in a user-friendly format.
Requirements:
- Use functions and data structures to organize the weather data.
- Implement error handling for cases such as invalid locations or unsupported units.
- Simulate fetching weather data from an API (you can use hardcoded data for the purpose of this exercise).
Sample Code Structure:
class WeatherService:
def __init__(self):
# Your code here
def set_location(self, city, country):
# Your code here
def get_weather_forecast(self):
# Your code here
def change_units(self, temperature_unit, wind_speed_unit):
# Your code here
def save_forecast(self, filename):
# Your code here
def display_forecast(self):
# Your code here
# Example usage:
weather_service = WeatherService()
weather_service.set_location("Tokyo", "Japan")
weather_service.get_weather_forecast()
weather_service.change_units("Celsius", "km/h")
weather_service.display_forecast()
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill