Write a function that is named positionQueries


Assignment

I. Position queries

Write a function that is named positionQueries that takes 2 lists as input such that the first list named data contains a list of unsorted integers and the second listx named order contains position queries. Order denotes the position of an element in the data list if it were sorted. Thus, though the order elements can contain any value(as described below) valid elements in order list cannot be less than 1 or greater than the length of the data list. The output will be the list of integers in the data list corresponding to the order of elements. If the input is bad print the message "bad input" and return to solve the next question.

II. The Round Trip

A certain robot can perform only 4 types of movement. It can move either up or down or left or right. These movements are represented by 'U', 'D', 'L', 'R'. Assume all these movements to be of unit distance. Write a function named theRoundTrip that takes all the movements the robot made in a day as input and output True of bool type if the robot returned to its starting position after its journey. Otherwise return False. If the input is bad print the message "bad input" and return to solve the next question.

III. The Secret Key

You are in pursuit of a treasure of great value. You just found the treasure chest but it is locked with 2 keyholes. Luckily, you had guessed this in the beginning of your quest and brought with you a bunch of keys. Each of the keys in your bunch seem to have an integer value associated with it.

Now, the chest is designed in such a way that any 2 keys that can combine (arithmetic sum) to generate the secret key value can open the chest. You start plugging in all sorts of combination of your keys in the 2 keyholes of the chest to check if you are lucky before you walk away in despair. Write a function called isSecretKey that tells you if you will be able to retrieve the treasure given your key bunch and the secret key value. True of type bool indicates you can retrieve the treasure. False means otherwise.

IV. The Alien Language

You are given a rare document that we suspect is written in an alien language. The alien language has the following grammar.

1. All its words read the same backward as well as forward. E.g. aba. A sequence of these words are written as sentences.

2. It is composed of only English alphanumeric([a-z, A-Z, 0-9]) characters in it.

3. It has exactly one space between each word.

4. It is case insensitive. i.e. aba is the same word as abA.

Write a function isAlienWord that takes an input word and returns if it is alien or not. Then, write another function called isAlienLanguage that calls the isAlienWord function for each word of its sentence and returns if the entire document is alien or not. For the document to be alien each and every single word in the document has to alien. True of type bool indicates the document is alien False means otherwise.

Format your assignment according to the following formatting requirements:

1. The answer should be typed, double spaced, using Times New Roman font (size 12), with one-inch margins on all sides.

2. The response also includes a cover page containing the title of the assignment, the student's name, the course title, and the date. The cover page is not included in the required page length.

3. Also include a reference page. The Citations and references should follow APA format. The reference page is not included in the required page length.

Download:- Assignment-Instruction.rar

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Write a function that is named positionQueries
Reference No:- TGS02987675

Expected delivery within 24 Hours