Dictionaries || Type C || Sumita Arora || Class 11 || Information Practices || Solution


Q1. Write a program to enter names of employees and their salaries as input and store them in a dictionary.




Q2. Write a program to count the number of times a character appears in a given string.




Q3. Write a program to convert a number entered by the user into its corresponding number in words.


Q4. Repeatedly ask the user to enter a team name and how many games the team has won and how many they lost. Store this information in a dictionary where the keys are the team names and the values are list of the form [wins, losses].(a) Using the dictionary created above, allow the user to enter a team name and print out the team’s winning percentage.(b) Using dictionary, create a list whose entries are the number of wins of each team.(c) Using the dictionary, create a list of all those teams that have winning records.



Q5. Write a program that repeatedly asks the user to enter product names and prices. Store all of these in a dictionary whose keys are the product names and whose values are the prices.When the user is done entering products and price, allow them  to repeatedly enter a product name and print the corresponding price or a message if the product is not in the dictionary.




Q6. Create a dictionary whose keys are month names and whose values are  number of days  in the corresponding months.(a) Ask the user to enter the month name and use the dictionary to tell how many days are in the month.(b) Print out all of the keys in alphabetical order  .(c) Print out all of the month with 31 days.(d) Print out the (key-value) pairs sorted by the number of the days in each month .


 




Q13. A dictionary has three keys: 'assets', 'liabilities' and 'capital'. Each of these keys store their value in form of a list storing various values of 'assets', liabilities' and 'capital' respectively. Write a program to create a dictionary in this form and print. Also test if the accounting equation holds true.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post