;

Tags: Python Dictionary Articles


Python Program to Count Words in a String Using Dictionary

Tutorialsrack 08/05/2020 Python

In this python program, we will learn how to count words in a string and put it into a dictionary. In this program, we will take the string input from the user and count the words and their frequency and put it into a dictionary as key-value pairs. In this program, we are doing this in two ways. The first way is using a python built-in count(), zip(), dict() and split() functions and the second way is using a count() and split() functions.

Read More..

Python Program to Map two lists into a Dictionary

Tutorialsrack 08/05/2020 Python

In this python program, we will learn how to map two lists into a dictionary. In this program, we use the python built-in zip() and dict() functions. The zip() is a Python built-in function and this function is used to Make an iterator that aggregates elements from each of the iterables. And The dict() is a Python built-in function and this function returns a dictionary object or simply creates a dictionary in Python.

Read More..

Python Program to Merge Two Dictionaries into Single Dictionary

Tutorialsrack 08/05/2020 Python

In this Python program, we will learn how to merge two dictionaries into a single dictionary. In this program, we used the python dictionary built-in functions and exponent operator to perform the concatenation of two dictionaries. We used the update(), dict() function and ** operator to merge two dictionaries in python.

Read More..

Python Program to Remove Given Key from a Dictionary

Tutorialsrack 06/05/2020 Python

In this Python program, we will learn how to remove a given key from a dictionary. In this program, we used the three ways to remove the key from the dictionary. The first way is, we used the del statement to remove a given key from a dictionary. The second way is to use the del statement with keys() function and the third way is to use the pop() function with the keys() function.

Read More..

Python Program to Multiply All the Items in a Dictionary

Tutorialsrack 06/05/2020 Python

In this Python program, we will learn how to multiply all the items in a dictionary. In this program, we are using two ways to multiply all the items in a dictionary. The first way is without using any python built-in functions and the second way is using python dictionary built-in values() function.

Read More..

Python Program to Find the Sum of Items in a Dictionary

Tutorialsrack 06/05/2020 Python

In this Python program, we will learn how to find the sum of the items in a given dictionary. In this program, we are using three ways to do this. The first way to find the sum of items in a dictionary is the python dictionary built-in function sum() and values() and the second way to find the sum of the item is using loops and python dictionary built-in values() function and the third way is without using any python built-in function.

Read More..

Python Program to Add Key-Value Pair to a Dictionary

Tutorialsrack 05/05/2020 Python

In this Python program, we will learn how to add key-value pairs to a dictionary. In this program, we are adding key-value pairs to a dictionary in two ways: the first way is to use the python dictionary built-in update() function to update the element in the dictionary and the second way is without using any python dictionary built-in function.

Read More..
Recent Posts
Tags