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": <Number>}" where
<Number> 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
Please let me know if you need more information:-
==========================================
import urllib.request
import json
def query_dict(mapping_strings):
url_to_send_request=r'https://fury.cse.buffalo.edu/ps-api/a'
#framing query to send with mapping strings - START
i=0
for pair in mapping_strings:
if i == 0:
url_to_send_request += "?";
else:
url_to_send_request += "&"
url_to_send_request += pair + "=" + str(mapping_strings[pair])
i=i+1
#framing query to send with mapping strings - END
#url_to_send_request=url_to_send_request+'?'+urllib.parse.urlencode(mapping_strings) #WAY-2 with urllib
print(url_to_send_request)
response_from_url=urllib.request.urlopen(url_to_send_request).read().decode()
json_response_from_url=json.loads(response_from_url)
return float(json_response_from_url['answer'])
mapping_strings={'x':15,'y':14,'z':25}
print("Floating noint number is:",query_dict(mapping_strings))
==
==
==
OUTPUT:-
====
https://fury.cse.buffalo.edu/ps-api/a?x=15&y=14&z=25
Floating noint number is: 3976.19
==
Please let me know if you need more information:-
==
Thanks
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...
Write a function named "find_key" that takes a key-value store as a parameter with strings as keys and integers as values. The function returns a boolean representing true if the string "focus" is in the input as a key, false otherwise(javascript)
python: Write a function named "write_values" that takes a key-value store mapping strings to strings as a parameter and writes the values of the input to a file named "persuade.txt" with one element per line. If a file named "persuade.txt" already exists it must be overwritten. The function should not return any value
Write a function named "find_value" that takes a key-value store as a parameter with strings as keys and integers as values. The function returns a boolean representing true if the value 4 is in the input as a value, false otherwise
Mapping Keys to Integer Values: Write a function mapKey() that can take a parameter of a. One String. For example: "Mary" or "lamb" or "a" or "" (null string) b. A list of Strings example: [ "Mary", "had", "a", "little", "lamb"] c. A Number d. A list of numbers And transforms the key to an integer numeric value by adding the numbers up in the list. You can use ord() to convert character to numberic or use a table lookup...
In JavaScript define a function named 'lowInventory' which will be called with a dictionary mapping strings to numbers and which returns the number of key-value pairs whose value is lee than or equal to 10. Example: lowInventory({'milk':14,'butter':5,'bread':37,'jam':8}) must return 2 lowInventory{{'oil':16,'filter':29,'grease':42,'hydraulic fluid':18}) must return 0
someone please help how do i make a request by using urllib.request? Write a function named "get_response" that three string parameters representing the protocol, name of a server, and a path for an HTTP GET request in this order. Return the response of an HTTPS GET request to the url formed by these inputs. Recall that a url will follow the format "<protocol>://<server_name>/<path>" The response should be returned as a string
Question 1: Write down an function named bitwisedFloatCompare(float number1, float number2) that tests whether a floating point number number1 is less than, equal to or greater than another floating point number number2, by simply comparing their floating point representations bitwise from left to right, stopping as soon as the first differing bit is encountered. The fact that this can be done easily is the main motivation for biased exponent notation. The function should return 1 if number1 > number2, return...
Define a JavaScript function named showScores which has one parameter which is a JSON blob (JSON encoding). The parameter encodes an object which maps strings to Numbers. This object will have the keys: "total" and "count". Your function should display the parameter's value associated with "total" in a div element whose id is "overall" . It must also display the parameter's value associated with "count" in a div element whose id is "num".
Define a JavaScript function named activityScore with one parameter. Assume the function will be called with an array of Numbers. Define the function so that it creates an Object. This object should have a key equal to "score", and its paired value should be set to the sum of the array’s entries. Return the JSON blob encoding the Object.