Ask Question
7 December, 03:06

Write a statement to add the key Tesla with value USA to car_makers. Modify the car maker of Fiat to Italy. Sample output for the given program:

+2
Answers (1)
  1. 7 December, 05:40
    0
    Input code:

    car_makers = {'Honda': 'Japan', 'Fiat': 'Germany'}

    #add Tesla and USA as corresponding value

    car_makers['Tesla'] = 'USA'

    #change Fiat entry to Italy instead of Germany

    car_makers['Fiat'] = 'Italy'

    print (car_makers)

    print ('Honda made in', car_makers['Honda'])

    print ('Fiat made in', car_makers['Fiat'])

    print ('Tesla made in', car_makers['Tesla'])

    Explanation:

    The first line is a define object in the python code, containing two entries of Honda and Fiat and their respective countries.

    The python code adds an entry to the object "car maker" using the bracket notation, the tesla car from USA.

    The country of the Fiat car is changed from Germany to Italy, using the bracket notation.

    The output of the complete object and the individual cars is given.

    output of the python code:

    {'Honda': 'Japan', 'Fiat': 'Italy', 'Tesla': 'USA'}

    Honda made in Japan

    Fiat made in Italy

    Tesla made in USA.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a statement to add the key Tesla with value USA to car_makers. Modify the car maker of Fiat to Italy. Sample output for the given ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers