single
Challenge: Hourly Temperature Extractor
Swipe to show menu
In this challenge, you will deepen your skills in working with real-world APIs by retrieving and processing hourly temperature data for a specific location. You will use the Open-Meteo API to fetch temperature readings for Paris, France (latitude: 48.85, longitude: 2.35). The goal is to extract the hourly temperatures from the API's JSON response and print the first five values. This task will test your ability to make HTTP requests, parse JSON data, and access specific values within the data structure.
Swipe to start coding
Write a function that fetches hourly temperature data for Paris from the Open-Meteo API and prints the first 5 temperature values.
API Request
- URL: https://api.open-meteo.com/v1/forecast ;
- Method: GET;
- Query parameters: latitude=48.85, longitude=2.35, hourly=temperature_2m;
Working with the Response
The API returns a JSON object. Extract the list of temperature values from the hourly → temperature_2m field, then print the first 5 values, each on a new line.
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat