Skip to content

Mr-Umidjon/dict_basic_homework

 
 

Repository files navigation

Welcome

Dictionary

Automated grading of homework assignments and tests

  • fork this repository
  • solve the task
  • commit with proper message

Problems

first_item

Given a dictionary, Return first item value.

Example 1:

Input: {'a': 1, 'b': 2}
Output: 1

last_item

Given a dictionary, Return last item value.

Example 1:

Input: {'a': 1, 'b': 2}
Output: 2

create_dictionary

Convert two lists into a dictionary

Example 1:

Input: key = [1, 2, 3] value = ["one", "two", "three"]
Output: {1: "one", 2: "two", 3: "three"}

Constraints:

  • len(key) == len(value)

count_all

Given a function that takes a string and calculates the number of letters and digits within it.

  • Tests contain only alphanumeric characters.
  • Spaces are not letters.
  • All tests contain valid strings.

Example 1:

Input: txt = "Hello World"
Output: { "LETTERS":  10, "DIGITS": 0 }

Example 2:

Input: txt = "python foundations 2022"
Output: {'LETTERS': 17, 'DIGITS': 4}

Constraints:

  • 0 <= len(txt) <= 10^5

oldest_person

Given a dictionary containing the names and ages of a group of people, return the name of the oldest person.

Example 1:

Input: people = {"Javohir": 22, "Sharof": 23, "Tolib": 34, "Rustam": 16}
Output: "Tolib"

Constraints:

  • 0 <= len(people) <= 10^5

cities_dict

Given a list of cities names, Return dictionary with keys ordered by city name.

Example 1:

Input: cities = ["Bukhara", "Khiva", "Namangan", "Samarkand", "Tashkent"]
Output: {0: "Bukhara", 1: "Khiva", 2: "Namangan", 3: "Samarkand", 4: "Tashkent"}

Constraints:

  • 0 <= len(cities) <= 10^5

Warning

  • don't copy other solutions or any solution
  • don't remove comments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%