Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
def sw_vehicle_search(cargo_capacity: int, max_speed: int, cost: int) -> list:
This function will use the https://swapi.dev/ API to collect its information. This function is meant to be used to search for vehicles in Star Wars that meet the specified criteria. The function should return a list of names of the vehicles that have cargo capacities and a max speed greater than or equal to the value specified but also cost less than or equal to the cost given. Vehicles with "unknown" or "none" for any of the mentioned categories should not be regarded.
Keep in mind that not all of the vehicles in star wars are returned in one request to https://swapi.dev/api/vehicles/. The JSON object returned by this request has a next attribute that represents the next page of information. You must make multiple requests for each page to collect all vehicle information.
You might find it helpful to use the following API handle(s):
https://swapi.dev/api/vehicles/ - to retrieve all vehicles in Star Wars
def starship_piloted_species(starship: str) -> list:
This function will use the https://swapi.dev/ API to collect its information. This function will be given a string that represents the name of a starship in star wars. It should return a list of names of species that have piloted the specified starship. The order of the list does not matter. If the pilot's species is empty, then the pilot is considered a "Human".
You might find it helpful to use the following API handle(s):
https://swapi.dev/api/starships/ - to retrieve all starships in Star Wars
def wear_a_jacket(us_zip:str) -> bool:
This function should use https://openweathermap.org/ API (user account required) to collect its weather information. The purpose of this function is to inform you if you should wear a jacket or not. It will be given a US zip code. This function should query the API to figure out the current temperature in the region associated with the US zip code. If the temperature is less than 60 degrees Fahrenheit (main.feels_like float:
This function should use https://openweathermap.org/ API (user account required) to collect its weather information. This function should retrieve the historical temperature in Fahrenheit at a particular US location. You will be given a number of days, hours, and minutes and a United States zip code. The time values given are the cumulative total time in the past minus the current time, you should retrieve the historical temperature (current.temp). In other words, if the parameter days is 4 hours is 0 and minutes is 5. Then you should return the temperature 4 days and 5 minutes ago at the specified zip code.
Since the open weather API does not have a method querying for historical weather with a zip code, please make use of this git hub document that maps US zip codes to latitude and longitude. https://gist.githubusercontent.com/erichurst/7882666/raw/5bdc46db47d9515269ab12ed6fb2850377fd869e/US%2520Zip%2520Codes%2520from%25202013%2520Government%2520Data Keep in mind, you might need to remove erroneous white space characters from the beginning and end of the latitude and longitude values in this document after splitting the line with a comma delimiter ",".
You might find it helpful to use the following API handle(s):
http://api.openweathermap.org/data/2.5/onecall/timemachine - to retrieve past weather information
def borders(country_name_a: str, country_name_b: str) -> bool:
Using the https://restcountries.com/ API, this function will answer the question, are two countries neighbors? The function will be given two arguments country_name_a and country_name_b. Both arguments are partial names of countries. The function's job is to find all nations with a name that contains country_name_a. Then check whether any countries are neighbors of the matching countries for country_name_b.
One challenging aspect of this problem is that the country's name will not be complete. For example, the partial country name may be "united" which will yield a long list of possible countries because many countries' official names include the word "united" for example, United States of America, United States Minor Outlying Islands, United Republic of Tanzania, United Mexican States, United Arab Emirates, and many more. Your goal is to check if the specified language is spoken in any countries that match the partial name. Use the endpoint https://restcountries.com/v3.1/name/{name} to get a complete list of countries with the partial name in their official name (replace {name} with the actual country_partial_name argument's value).
The endpoint https://restcountries.com/v3.1/name/{name} will return a lot of information about each country. The critical bits you want to look at are the keys "borders" and "cca3". The key "borders" will tell you which country(s) border the given nation. The value associated with the key "borders" will be a list of 3-letter country codes. Remember that the key "border" will not be in the dictionary if the nation has no neighbors because it's an island. The key "cca3" will tell you the 3-letter country code for the given nation.
The function should return True if a country matching country_name_a borders a country matching country_name_b.
Example:
assert borders("united", "united")
assert borders("sweden", "republic")
assert not borders("united", "tanzania")
assert not borders("british", "sweden")
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- 10 mplete out of question Complete the transform_2d_list() function that takes a single two-dimensional list as a parameter called a_2d_list. The parameter list has m items, where each item is a list with n items. The function returns a new two-dimensional list, where the first item is a list containing all of the first items in the list items of the original list, and the second item is a list containing all of the second items in the list items of the original list and so on. In other words, the two- dimensional list that is returned will have n items, where each item is a list with m items. You can assume that both m and n are at least 1. Some examples of the function being called are shown below. For example: Test a_2d_list = [[1]] print (transform_2d_list (a_2d_list)) a_2d_list = [['a'], ['b']] print (transform_2d_list (a_2d_list)) a_2d_list = [[1, 2], [3, 4]] print(transform 3d lint( Result [[1]] [['a', 'b']] [[1, 3], [2, 4]]arrow_forwardPython question, need some helparrow_forwardF3 Match std::vector method on left to the respective description on right. emplace pop_back capacity R 4 size data $ F4 Q Search % 5 DII T F5 6 V [Choose] [Choose] Returns the size of the storage space currently allocated for the vector, expressed in terms of elements. Returns the maximum number of elements that the vector can hold. Removes the last element in the vector, effectively reducing the container size by one. The vector is extended by inserting a new element at a given position Returns a direct pointer to the memory array used internally by the vector to store its owned elements. The vector is extended by inserting new elements before the element at the specified position, effectively increasing the container size by the Returns the number of actual objects held in the vector Adds a new element at the end of the vector, after its current last element Inserts a new element at the end of the vector, right after its current last element [Choose] [Choose ] F6 L 10 7 F7 11 > C >…arrow_forward
- Define the function number_in_trophic_class(tli3_values, classification) which takes a list of trophic level index values and a trophic classification, returning the number of lakes in that trophic class. For this version of the question you MUST use a list comprehension. You cannot use a for loop or while loop in your answer. Notes: You must include, and use/call your trophic_class function in your submission. Your tropic_class function must work in the same way it did for Question 2. You can assume that classification will always be valid, i.e. it will always be one of the states in the following list: ['Hypertrophic', 'Supertrophic', 'Eutrophic', 'Mesotrophic', 'Oligotrophic', 'Microtrophic', 'Ultra-microtrophic'] There are several ways to proceed, but you will probably find either the len function or the count method of the list class useful in conjunction with your list comprehension. For example: Test Result tli3_list_1 = [4.1061, 2.54561, 4.16276, 2.33801,…arrow_forwardWhat are the values of the variable number and the vector review after the following code segment is executed? vector<int> review(10,-1); int number; number = review[0]; review[1] = 150; review[2] = 350; review[3] = 450; review.push_back(550); review.push_back(650); number += review[review.size()-1]; review.pop_back();arrow_forwardPython code please help, indentation would be greatly appreciatedarrow_forward
- When using List functions, a _____________ parameter can be used to limit the values returned.arrow_forwardInserting Nodes into the List In the following code (This is Code By C) : there are 3 functions : display, insert_begin, and delete. The request is add two functions : First Function (insert_last) : to insert values from last. Second Function (insert_mid): to insert values from Middle. The code: #include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h> struct node{int info;struct node* next;}; struct node* start; void display();void insert_begin(); void delete(); int main(){ int choice;start = NULL; while (1){printf("\n\t\t MENU \t\t\n");printf("\n1.Display\n");printf("\n2.Insert at the beginning\n");printf("\n3.Insert at the end\n");printf("\n4.Delete\n");printf("\n5.Exit\n"); printf("Enter your choice:\t");scanf_s("%d", &choice); switch (choice){case 1:display();break;case 2:insert_begin();break;case 3:delete();break;case 4:exit(0);break;default:printf("\nWrong Choice.\n");break;} }return 0;} void display(){struct node* temp;if (start ==…arrow_forwardDefine the function lake_to_tli3_dict(readings) that takes a list of (lake_name, chla, tn, tp) tuples and returns a dict mapping lake names to trophic level index values. That is, the keys are lake names and the values will be TLI3 values. Notes: You will need to have import math as your first line of code. You must include and use/call the trophic_level_index function that you wrote in Question 1. trophic_level_index must still work as specified in Question 1. Lakes should be added to the dictionary in the same order as they appear in the readings list. If a lake appears in the readings list more than once, then the TLI for the last occurrence in the readings list should be the one that appears in the result. (This should happen naturally, since the lake name can only occur in the dictionary once.) For example: Test Result names_cnp_1 = [('Lake Brunner', 0.8, 218.0, 6.0), ('Lake Carrot', 5.1, 505.0, 18.5) ] tli3_dict = lake_to_tli3_dict(names_cnp_1 ) print(tli3_dict)…arrow_forward
- Using the data file below design a hierarchical struct to organize the data. Then declare an array of structs for the reservations. The data file contains ten reservations. There are 8 columns of data: party name, size, date and time for the reservation, phone number, email address, credit card number and expiration date for the credit card. The data can be read from the file below so you will not need to type it in repeatedly. Once you have populated the array with data perform the following tasks: Write a function that will print out to the screen the information for one reservation.In the main program write code that prompts the user to enter a date in the form MM DD YYYYCall the function to print out all reservations on that date. You can make a loop that calls the print function repeatedly or you can put that code inside the print function.TEST CASES: April 30, 2023 and May 12, 2023. In this example you need to carefully consider what data types to use. For example, the credit…arrow_forwardComputer Science csv file "/dsa/data/all_datasets/texas.csv" Task 6: Write a function "county_locator" that allows a user to enter in a name of a spatial data frame and a county name and have a map generated that shows the location of that county with respect to other counties (by using different colors and/or symbols). Hint: function(); $county ==; plot(); add=TRUE.arrow_forwardNeed some help on this Python Quesionarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education