12 мая 2022
Thamin🪿Фотография
Please can you share with me the complete solution for this.... I mean the full screen so I can study
id 5386240094Please can you share with me the complete solution for this.... I mean the full screen so I can study
#i
language = []
for item in countries_info:
for items in item['languages']:
if items in language:
continue
else:
language.append(items)
print(language)
print(len(language))
#ii
lang_counter = {}
for item in countries_info:
for lang in item['languages']:
if lang in lang_counter:
lang_counter[lang] += 1
else:
lang_counter[lang] = 1
popular_langs = sorted(lang_counter, key = lang_counter.get, reverse = True)
top_10 = popular_langs[:10]
print(top_10)
# here we use a dictionary and we add item, we add the language as key and the numbers of the repeatation as value.
# every time it see the language again it add to the number.
#sorted : key---> it show how to sort and here we use the value to be sorted(numbers of repeat)
#reverse = true ---> from most to least.
#iii
population = []
for item in countries_info:
population.append(item['population'])
most_pop = sorted(population, reverse = True)
top_10 = most_pop[:10]
print(top_10)
most_10 = []
for i in top_10:
for item in countries_info:
if i == item["population"]:
most_10.append(item['name'])
print(most_10)
id 1745093205текст ещё не в индексе
That's not true, it was a convention of programming about math topic(common in MATLAB) but in math you use 2(elevate n)