1. Write a program that reads a string from keyboard and prints the unique words. Your program should convert input string to lower case. Solution
2. Write a program to print all elements in a list those have only single occurrence.
Example: if contents of list is [7, 5, 5, 1, 6, 7, 8, 7, 6].
Your output should be:
1 8
Solution
3. Write a program to enter names of employees and their salaries as input and store them in a dictionary. Solution
4. Write a program to read 6 numbers and create a dictionary having keys EVEN and ODD. Dictionary's value should be stored in list. Your dictionary should be like:
{'EVEN':[8,10,64], 'ODD':[1,5,9]}
Solution
5. Write a program that reads string from user. Your program should create a dictionary having key as word length and value is count of words of that length. For example, if user enters 'A fat cat is on the mat'.
Word | Word length |
A | 1 |
fat | 3 |
cat | 3 |
is | 2 |
on | 2 |
the | 3 |
mat | 3 |
The content of dictionary should be {1:1, 3:4, 2:2}
Solution
6. Write a program to input roll numbers and their names of students of your class and store them in the dictionary as the key-value pair. Perform the following operations on the dictionary:
a) Display the Roll numbers and name for all students.
b) Add a new key-value pair in this dictionary and display the modified dictionary
c) Delete a particular student's record from the dictionary
d) Modify the name of an existing students.
Solution