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
Leto [7]
3 years ago
9

We have provided a list of tuples called state_capitals. The first item in every tuple is the name of a US state and the second

item in that tuple is the capital of that state. Write code that converts this data structure into a dictionary where the keys are state names and the values are state capitals. Assign the result to the variables capitals_dict.state_capitals = [ ('Michigan', 'Lansing'), ('Massachusetts', 'Boston'), ('Pennsylvania', 'Harrisburg'), ('New York', 'Albany')]
Computers and Technology
1 answer:
Rainbow [258]3 years ago
7 0

Answer:

The solution code is written in Python:

  1. state_capitals = [ ('Michigan', 'Lansing'), ('Massachusetts', 'Boston'), ('Pennsylvania', 'Harrisburg'), ('New York', 'Albany')]
  2. capitals_dict = {}
  3. for x in state_capitals:
  4.   capitals_dict[x[0]] = x[1]
  5. print(capitals_dict)

Explanation:

Firstly, we create a variable capitals_dict and initialize it with a empty dictionary (Line 3).

Next, we use the for-loop to traverse through each tuple item in the state_capitals list (Line 5). Within the loop, we use the syntax x[0] to take out the first item (state) from the tuple and use it as the key capitals_dict[x[0]]. We use the syntax x[1] to take out the second item (capital) from the tuple and set it as the value of the dictionary (capitals_dict[x[0]].). (Line 6)

When finishing the loop, we can print the dictionary (Line 7) and the output is as follows:

{'Michigan': 'Lansing', 'Massachusetts': 'Boston', 'Pennsylvania': 'Harrisburg', 'New York': 'Albany'}

You might be interested in
7.2 need help plzs 15 points
Natalka [10]
So you have to read it and make it a pronoun
3 0
3 years ago
Write a program that accepts as input the mass, in grams, and density, in grams per cubic centimeters, and outputs the volume of
rewona [7]

Answer:

Program for the above question in python:

mass = float(input("Enter the mass in grams")) # It is used to take the mass as input.  

density = float(input("Enter the density grams per cm cube")) # It is used to take the input for the grams.

print("Volume ={:.2f}".format(mass/density)) #It is used to print the Volume.

Output:

  • If the user inputs as 2.98 and 3.2, then it will results as 0.92.

Explanation:

  • The above code is in python language, in which the first statement is used to take the inputs from the user for the mass and sore it into a mass variable.
  • Then the second statement also takes the input from the user and store it into a density variable.
  • Then the third statement of the code is used to print the volume up to two places using the above-defined formula.
3 0
4 years ago
- What are the different types of clients?
Nataly_w [17]

Answer: Different types of client are 1. Thick 2. Thin 3.Hybrid

Explanation:

A Thick client, also known as a rich client or fat client, is a client that performs the bulk of any data processing operations itself, and does not necessarily rely on the server.

A thin client is a minimal sort of client. Thin clients use the resources of the host computer.

A hybrid client is a mixture of the above two client models. Similar to a fat client, it processes locally, but relies on the server for storing persistent data.

7 0
4 years ago
In the __________ Standard, chemical manufacturers, importers, and distributors are required to provide hazard information by wa
STatiana [176]

Answer is C: Hazard Communication

Hazard Communication Hazard (HCS 2012) provides a coherent and standardized approach to communicating the hazards of chemicals by way of Safety Data Sheets (SDSs) and labels on containers. However, Occupational Safety and Health Administration (OSHA) revised its HCS 2012. In it, they revised criteria for classification of chemical hazards, labeling provisions, hazard statements, and precautionary statements.  In addition, modifications were made to health standards substances to ensure requirements for labels and SDSs are consistent with the HCS 2012. According to OSHA’S standards, SDSs should periodically be reviewed and updated.

7 0
4 years ago
Read 2 more answers
What are some objects in your home that demonstrate electrical energy to radiant energy to thermal energy
Bogdan [553]
Definitely a lamp or a stove
6 0
3 years ago
Read 2 more answers
Other questions:
  • A motherboard uses dual channeling, but you have four DIMMs available that differ in size. The motherboard supports all four siz
    7·1 answer
  • You are a network security administrator for a bank and you have noticed that an attacker has exploited a flaw in OpenSSL and fo
    9·1 answer
  • Write c++ program bmi.cpp that asks the user bmi.cpp the weight (in kilograms) and height (in meters).
    12·1 answer
  • Write an HTML document which contains two text fields, a button, and a div. The first text field should be labeled “Temperature”
    10·1 answer
  • The decimal number 3 is ___ in binary the 2s column plus the 1s column.
    11·1 answer
  • IF YOU PLAY SURVIV&gt;IO WITH ME RIGHT NOW I WILL GIVE YOU BRAINLIEST<br> AND IM NOT KAPPING
    5·1 answer
  • In this section of your final project, you will write a basic script to create and back up files. You will create this script wi
    11·2 answers
  • AYUDAAA ESPARA HOYYY
    14·2 answers
  • Which is the fastest memory in computer​
    9·2 answers
  • Kenny is asked to submit a photo for the annual photographic competition. He decided to capture a photo with the light-painting
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!