Lab Report 06
Lab Report 06
RAWALPINDI
Lab Number # 06
SUBMITTED TO:
SUBMITTED BY:
Muhammad Talha
REG NO # 481402
Write a function that takes two lists of numbers and returns a new list that contains the elements
that are present in both lists. The length of the lists can be different.
CODE:
Output:
Write a function that takes two dictionaries and does the following:
• If a key exists in both the dictionaries, the values a added
• Else, the key: value pair is added to a new dictionary.
• The final dictionary is returned.
a = {‘one’: 12, ‘two’: 10, ‘three’:22},
b = {‘four’:14, ‘one’:10, ‘three’: 2}
c = {‘one’: 22, ‘two’: 10, ‘three’: 24, ‘four’: 14}
CODE:
# Define dictionaries
dict1 = {"one": 12, "two": 10, "three": 22}
dict2 = {"four": 14, "one": 10, "three": 2}
# Call the function and store the result
my_dict = result(dict1, dict2)
OUTPUTS:
**************************************************************************