Skip to content
Pooja Bhatia Classes Hari Nagar
  • We teach following classes
    • Class 12
    • Class 11
    • Class 10
    • Class 9
  • Sumita Arora IP/CS Solutions
  • Jobs/Internship
Pooja Bhatia Classes Hari Nagar

2 BE C

9. Create a dictionary whose keys are month names, and whose values are the number of days in the corresponding months.

sa 12 cs chapter 2 / PythonCSIP CS IP

9. Create a dictionary whose keys are month names, and whose values are the number of days in the corresponding months. Read More »

10. Write a function called addDict(dict1, dict2) which computes the union of two dictionaries. It should return a new dictionary, with all the items in both its arguments (assumed to be dictionaries). If the same key appears in both arguments, feel free to pick a value from either.

sa 12 cs chapter 2 / PythonCSIP CS IP

# Code def addDict(dic1, dic2): new_dic = {} for i in dic1.keys(): # all the keys will be put into the new_dic new_dic[i] = dic1[i] for i in dic2.keys(): # keys common in both the dictionaries will have the values of dic2 in the new_dic new_dic[i] = dic2[i] return new_dic dic1 = {‘a’:1, ‘b’:2, ‘c’:3}

10. Write a function called addDict(dict1, dict2) which computes the union of two dictionaries. It should return a new dictionary, with all the items in both its arguments (assumed to be dictionaries). If the same key appears in both arguments, feel free to pick a value from either. Read More »

Post pagination
← Previous 1 2 3 … 7 Next →
  • We teach following classes
    • Class 12
    • Class 11
    • Class 10
    • Class 9
  • Sumita Arora IP/CS Solutions
  • Jobs/Internship
  • We teach following classes
  • Sumita Arora IP/CS Solutions
  • Jobs/Internship

Copyright © 2025 Pooja Bhatia Classes Hari Nagar | Powered by Pooja Bhatia Classes Hari Nagar.