chore: import upstream snapshot with attribution
Validate YAML Workflows / Validate YAML Configuration Files (push) Has been cancelled
Validate YAML Workflows / Validate YAML Configuration Files (push) Has been cancelled
This commit is contained in:
Executable
+34
@@ -0,0 +1,34 @@
|
||||
def get_city_num(city: str) -> dict:
|
||||
"""
|
||||
Fetch the city code for a given city name.
|
||||
Example response:
|
||||
{
|
||||
"city": "Beijing",
|
||||
"city_num": "1010",
|
||||
}
|
||||
"""
|
||||
return {
|
||||
"city_num": 3701
|
||||
}
|
||||
|
||||
def get_weather(city_num: int, unit: str = "celsius") -> dict:
|
||||
"""
|
||||
Fetch weather information for the city represented by ``city_num``.
|
||||
Example response:
|
||||
{
|
||||
"city_num": "1010",
|
||||
"temperature": 20,
|
||||
"unit": "celsius"
|
||||
}
|
||||
"""
|
||||
temperature_c = 15 # Hardcode the temperature value
|
||||
if unit == "fahrenheit":
|
||||
temperature = temperature_c * 9 / 5 + 32
|
||||
else:
|
||||
temperature = temperature_c
|
||||
|
||||
return {
|
||||
"city_num": city_num,
|
||||
"temperature": temperature,
|
||||
"unit": unit
|
||||
}
|
||||
Reference in New Issue
Block a user