Question

python:Write a function named "query_dict" that a key-value store as a parameter mapping strings to floating...

python:Write a function named "query_dict" that a key-value store as a parameter mapping strings to floating point numbers. The function will make an HTTPS GET request to the url "https://fury.cse.buffalo.edu/ps-api/a" with a query string containing the same key-value pairs from the input key-value store. The response from the server will be a JSON string representing an object in the format "{"answer": }" where is a floating point Number. Return the value at the key "answer" as a float Recall that you may need to convert the numbers to strings

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot of code and output :-

Code in text format :-

# module for http get request
import requests
# api endpoint
URL = "https://fury.cse.buffalo.edu/ps-api/a"
reply = float
# defining a params dictionary
PARAMS = {'answer':reply}
# sending get request and saving the response as response object
re = requests.get(url = URL, params = PARAMS)
# extracting data in json format
data = re.json()
# extracting answer from json string
reply = data['answer']
print(reply)

Add a comment
Know the answer?
Add Answer to:
python:Write a function named "query_dict" that a key-value store as a parameter mapping strings to floating...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT