(part 1)

#Membership operators:

If you don’t know about membership operators, then GOOGLE it as “What are membership operators in python?“.

1

2

3

4

5

6

7

8

# Creating a Dictionary

Dict = {1: 'LetsUpgrade', 'Hi': 'New', 3: 'Batch'}

'Hi' in Dict

>>> True #Output

'Any Value' in Dict

>>> False #Output

#Python Iterate Dictionary:

We can also iterate on a Python dictionary like on a list, tuple, or set:

1

2

3

4

# Creating a Dictionary

iterate= {1: 1, 3: 3, 4: 4}

for i in iterate:

    print (iterate[i]*2) 

Output:

2
6
8

Therefore, in above example, for every key in the dictionary, multiplies its value by 2 and then prints it.

Below FOUR are the complex topics and therefore, request you to go through each Article:

#Python Dictionary Comprehension:

We can also create a Python dict using comprehension. And, if you don’t know about comprehension, then GOOGLE it as “What is comprehension in python?“.

1

2

LetsUpgrade={x:x*x for x in range(8)}

LetsUpgrade

Output:

{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49}

Hence, in above example, we created a Python dictionary to generate the desired result as shown above.

————————————————- THE END —————————————————-

-Yogesh Raghupati (Author)