Write a program to check whether the given key is present in the dictionary.
If the key is present then display the value of the entered key and if the key is not present then display the appropriate message.
Input:
1.Get two dictionaries key-value elements
2. Get the key value to be searched
Output:
1. Display the first dictionary
2. Display the second dictionary
3. Display the concatenated dictionary
4. Display whether the key is present or nor and the respective value of the key.
Refer sample input and output for formatting specification.
INPUT:
81
9
64
8
81
OUTPUT:
First Dictionary: {81: 9}
Second Dictionary: {64: 8}
Concatenated dictionary is {81: 9, 64: 8}
Key is present and value of the key is 9
d1={} a=int(input()) b=int(input()) d1[a]=b d2={} c=int(input()) d=int(input()) d2[c]=d print('First Dictionary: ',d1) print('Second Dictionary: ',d2) d1.update(d2) print('Concatenated dictionary is ', d1) val=int(input("\nEnter Key: ")) c=0 for k,v in d1.items(): if k==val: c=c+1 print("Key is present and value of the key is ",v) if c==0: print("Key not present")
OUTPUT_1:
81
9
64
8
First Dictionary: {81: 9}
Second Dictionary: {64: 8}
Concatenated dictionary is {81: 9, 64: 8}
Enter Key: 81
Key is present and value of the key is 9
OUTPUT_2:
56
65
25
20
First Dictionary: {56: 65}
Second Dictionary: {25: 20}
Concatenated dictionary is {56: 65, 25: 20}
Enter Key: 25
Key is present and value of the key is 20
OUTPUT_3:
100
101
555
556
First Dictionary: {100: 101}
Second Dictionary: {555: 556}
Concatenated dictionary is {100: 101, 555: 556}
Enter Key: 100
Key is present and value of the key is 101
ILLUSTRATION
![](http://www.fcukthecode.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-22-19-11-36.png)
Morae Q!
- OS operating system module using path parameter.
- Find the smallest and largest integers after sorting using bubble sort.
- Find the integer and its number of occurrences.
- Algorithm complexity – Big O Notation with Examples.
- Linear search.
- Map module using series mapping and parallel mapping.
- Mapping and Transposing with Map Module.
- Map Module/built-in Function.
- Linux commands for managing files.
- Program which takes two lists and maps two lists into a dictionary.
- Splitting strings and substituting using regular expressions regex.
- Basics of regular expression Regex.
- Find the square value of the dictionary.
- Check whether the given key is present in the dictionary.
- Matching an expression only in specific places using regular expressions.
- Escaping special characters using regular expressions.
- Check the key.
- Grouping and sub-grouping using regular expressions.
- Generate a Dictionary that Contains Numbers in the Form (x , x*x).
- Algorithm complexity Big-Theta, Big-Omega and Big-O Notations.