Ask Question
20 March, 07:36

What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.) cities = {'GA' : 'Atlanta', 'NY' : 'Albany', 'CA' : 'San Diego'} if 'FL' in cities: del cities['FL'] cities['FL'] = 'Tallahassee' print (cities)

+1
Answers (1)
  1. 20 March, 09:24
    0
    Nothing will be printed

    Explanation:

    You can easily find out that FL is not a member of the Dictionary. And we are checking these in the if. Since the if condition ends up being false, the further process will not run as they will only if the condition ends up being true. Hence, nothing will be printed.

    Remember, del is used to delete a dictionary item. If this would have been a true condition for if then the FL item in the dictionary would have been deleted as it, in that case, would have been present there. And then the next line would have again added the FL item, and print would have printed the dictionary items with FL item as well. However, since if the condition is ending up being false, nothing will be printed.

    If cities['FL'] and print is outside if then

    the output will be

    {'FL': 'Tallahassee', 'GA': 'Atlanta', 'NY': 'Albany', 'CA': 'San Diego'}
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers