OOP Homework Exercise
Instructions
Create a Python program that models weather conditions using a single class, Weather. This class will hold information about a city's weather and provide methods to set and display these details.
Weather Class Description
-
Attributes:
- city_name (str): The name of the city.
- temperature (float): The current temperature in Celsius.
- condition (str): The current weather condition (e.g., "Sunny", "Rainy").
-
Methods:
- __init__(self, city_name): Initializes a new Weather object with the provided city name and default temperature and condition values.
- set_weather(self, temperature, condition): Sets the temperature and weather condition.
- display_weather(self): Prints the weather details in a readable format. (see output)
Requirements
- Create an instance of the Weather class for a city.
- Use the set_weather method to update the weather conditions and temperature.
- Display the weather information using the display_weather method.
Example Output
City: Paris
Temperature: 18°C
Condition: Sunny