Soru
Part 3 (30pts) Write Python statements that will create a set of countries from the dictionary of cities and print the countries in sorted order as seen in the sample run below. Hint: Create a list from the set of countries, then sort this list. Part 3: Countr ies: Brazil . China France Italy Japan Turkiye UK USA
Çözüm
4.4
(346 Oylar)
Janset
Usta · 5 yıl öğretmeni
Uzman doğrulaması
Cevap
Here is the Python code that will create a set of countries from the dictionary of cities and print the countries in sorted order:```python# Dictionary of citiescities = { "Brazil": "Brasilia", "China": "Beijing", "France": "Paris", "Italy": "Rome", "Japan": "Tokyo", "Turkiye": "Ankara", "UK": "London", "USA": "Washington D.C."}# Create a set of countriescountries = set(cities.keys())# Print the countries in sorted ordersorted_countries = sorted(countries)print("Countries:", ", ".join(sorted_countries))```Sample output:```Countries: Brazil, China, France, Italy, Japan, Turkiye, UK, USA```