1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ne4ueva [31]
3 years ago
14

The function below takes two arguments: a dictionary of strings (keys) to integers (values) a_dict and a list of strings key_lis

t. All of the strings in the list are keys to the dictionary. Complete the function such that it looks up each of the keys in the list and returns a list of their associated values. The order of the values in the list is based on the order of the keys in key_list. For example, with the dictionary {"puffin": 5, "corgi": 2, "three": 3} and the list ["three", "corgi"], your function should return [3, 2]. student.py
Computers and Technology
1 answer:
vitfil [10]3 years ago
8 0

Answer:

  1. def getData(a_dict, key_list):
  2.    result = []
  3.    for key in key_list:
  4.        result.append(a_dict[key])
  5.    
  6.    return result  
  7. result = getData( {"puffin": 5, "corgi": 2, "three": 3} , ["three", "corgi"])
  8. print(result)

Explanation:

Let's define a function <em>getData() </em>with two parameters,<em> a_dict </em>and <em>key_list</em> as required by the question (Line 1).

Since the function is to return a list of associated values of dictionaries, a new list,<em> result</em>,  is declared and initialized with empty values (Line 2).

Next, use for-loop to traverse through every string in the input <em>key_list </em>(Line 4) and use the traversed key to address the value in the<em> a_dict </em>and add it to the <em>result</em> list (Line 5)

At last, return the <em>result </em>list as output (Line 7)

We can test the function using the test case from the question and we shall see the output as follows:

[3, 2]

You might be interested in
Declare a typedef struct named jumper_t that will have four parts: character array name that is 16 in length, double array of tr
Maurinko [17]

Answer:

The typedef struct is as follows:

typedef struct jumper_t {

  char name[16];

  double tries[N_TRIES];

  double best_jump;

  double deviation;

} jumper_t;

The declaration of jlist is:

jumper_t jlist[10];

Explanation:

This defines  the typedef structure

typedef struct jumper_t {

The following declares the variables as stated in the question

<em>   char name[16]; </em>

<em>   double tries[N_TRIES]; </em>

<em>   double best_jump; </em>

<em>   double deviation; </em>

}

This ends the typedef definition

jumper_t;

(b) The declaration of array jlist is:

jumper_t jlist[10];

6 0
3 years ago
What is the meaning of web browser
anastassius [24]
Is that a joke... if ain't cheatin you repeatin
8 0
2 years ago
In NumPy, the_______
Nikolay [14]

Numpy is among the most prevalent science computer science bundles in Python, and the following are the discussion on the use of transpose function:

  • Transpose() is among the most important <em>matrix multiplication functions</em>.
  • It is used to changes elements of the <em><u>row into column</u></em> elements and the elements of the <em><u>column into rows</u></em> elements.
  • The output of this function is an original modified array.

Therefore, the transpose function in NumPy is being used to <em><u>switch positions of rows to columns or columns to rows</u></em>.

Learn more:

brainly.com/question/24763535

7 0
1 year ago
What is the difference between password protection and encryption? please answer quick, i cant pass this test for the life of me
sergiy2304 [10]

Answer:Password protection is like locking something in a safe-deposit. It means no one can get to the locked content without knowing the right combination. This method is used on separate documents, folders, and other data the computer's user may want to protect from other people who might have access to the device. The problem is, if someone interested in such content obtains the password or finds a way to open it without it, the content might be revealed despite the owner's efforts to keep it hidden. Unfortunately, there are a lot of ways hackers could obtain the password or hack in without it. For example, it could be obtained with the help of malware, or it might be guessed if the user chooses a weak password. Not to mention, when it comes to PDF documents, the passwords placed on them can be removed using the CMD window or specific.

Password encryption is a step up from password protection. The term can be a tad confusing because, in fact, you cannot encrypt the password itself. Instead, by setting up "password encryption" you are creating a password AND encrypting the contents of the file. In our example (see instructions below), the contents of the user's PDF document are not only password protected, but also encrypted. It is a process during which the content one wishes to keep secret is altered to make it unrecognizable. For example, if it is a text document, letters of each word might be shuffled with additional characters so the words would no longer make any sense. The reverse process is only available if the person who wants to decrypt this data can provide a specific decryption key or a password. In other words, even if the password is removed no one could read the hidden content as it still would need to be decrypted. Of course, it is important to realize you might be unable to retrieve it too if you lose the decryption key, aka, the password.



PLS MARK ME AS BRAINLIEST.

3 0
2 years ago
Yo who do u add a pic on here
Juliette [100K]
Go to the me colum when you first open the app
8 0
3 years ago
Other questions:
  • Describe what is meant by the following:
    14·1 answer
  • what aspect should you consider before adding pictures to a document? you should structure the first before you search for a rel
    15·2 answers
  • Search engine ranking evaluates the variables that search engines use to determine where a URL appears on the list of search res
    7·1 answer
  • What is a VIN and what role does it play during a criminal investigation? Explain how a VIN could help in a bomb and/or arson ca
    12·1 answer
  • A is a paid placement that appears in a search engines results page at or near the top of the results
    5·1 answer
  • There are many different types of decision-making. Which of the following is NOT a type of decision-making? a. fiat rule b. sing
    15·2 answers
  • Using underlining and italics at the same time is which of these? A. allowed but might be overkill B. always a good idea C. not
    15·2 answers
  • Which of the displays could be represented by a single bit?
    12·2 answers
  • Write a method named printGPA that takes in as a parameter a Scanner to read in user input, and calculates a student's grade poi
    8·1 answer
  • What is the missing line of code?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!