Junior — Middle
Can you give an example of interaction and data exchange between different systems?
sobes.tech AI
Answer from AI
Interaction and data exchange between different systems are often implemented through APIs, protocols, or intermediate data formats.
Example in Python — retrieving data from a REST API and processing the response:
import requests
# Send a GET request to an external service
response = requests.get('https://api.example.com/data')
if response.status_code == 200:
data = response.json() # Parse JSON response
# Process data
for item in data['items']:
print(item['name'], item['value'])
else:
print('Error fetching data:', response.status_code)
This approach allows integrating different systems, exchanging information in a standardized format (JSON, XML), and building distributed applications.