HomeCHAPTER CLASS 11 Dictionaries || Sumita Arora || Class 11 || Practical || Computer Science || Solution 9 Comments Facebook Twitter Dictionaries || Sumita Arora || Class 11 || Practical || Computer Science || SolutionP.I.P:- 9.1Q1. Suppose that D is the dictionary {"what" : 22, "are" : 11, "you" : 14, "doing" : 5, "next" : 9, "Saturday?" : 4}. Write down what the value of D is after each of the following Python statements. Evaluate each statement starting with the same value of the dictionary D, mentioned above and write what will be the change dictionary D?(a) D ["what"] = D ["are"](b) D.update ({"Sunday":25, "what":5})(c) del D["you"](d) D ["which"] = 19(e) D.clear ()Q2. Assume that price_dict is a Python variable to which a dictionary literal has already been assigned, and that it currently contains at least 10 key-value pairs.(a) write an expression whose value would be the number of key-value pairs in price_dict(b) write an expression that would be the value corresponding to the key 'avocados' in price_dict(c) write an expression that would be a list of all of the keys within price_dict(d) write an expression that would be a list of all of the keys values within price_dict(e) write a statement that would replace the current value of the key apples' in price_dict with 1.99Q3. Complete the following code and predict the output:# Data to count.names = ['tern', 'goose', 'goose', 'hawk', 'tern', 'goose', 'tern']#Build a dictionary of frequencies.freq = ___________ #creates an empty dictionaryfor name in names: # Already seen, so increment count by one. if ____ in ____ : # check for existence of name in dictionary freq freq[name] = freq[name] + 1: # Never seen before, so add to dictionary. else: freq[name] = 1# Display.print (freq)Q4. Predict the output of the following code:birthday = { 'Newton' : 1642, 'Darwin' : 1809, 'Turing' : 1912}print ('keys :', birthday.keys())print ('values :', birthday.values())print ('items:', birthday.items())print ('get:', birthday.get('Curie', 1867))temp = { 'Curie' : 1867, 'Hopper' : 1906, 'Franklin' : 1920}birthday.update(temp)print ('after update:', birthday)birthday.clear()print ('after clear:', birthday)Q5. Write a program that uses a dictionary that contains ten usernames and passwords. The program should ask the user to enter their usernames and passwords. If the username is not in the dictionary, the program should indicate that the person is not a valid user of the system. If the username is in the dictionary, but the user does not enter the right password, the program should say that the password is invalid. If the password is correct, then the program should tell the user that they are now logged into the system.
q.2 not there
ReplyDeleteSorry we do not Theory type questions .
Deletepls bro give theoy type as well
ReplyDeleteWe are working. It will come very soon.
Delete2nd and 3rd question please
ReplyDeleteplease upload 2 and 3
ReplyDeleteplease upload 2 and 3 questions fastly mam
ReplyDeletehi
ReplyDeleteim thomas sheby
woahowowowawoowwo
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )