Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

ds-checkpoint

February 10, 2024

0.1 Question
Write a Python program that multiplies all the items in a list.
Sample list= [2, 3, 6]
Result = 36
[1]:

[1]: 36

0.2 Question
Write a Python program that combines two dictionaries by adding values for common keys.
d1 = {‘a’: 100, ‘b’: 200, ‘c’:300}
d2 = {‘a’: 300, ‘b’: 200, ‘d’:400}
Expected result: {‘a’: 400, ‘b’: 400, ‘d’: 400, ‘c’: 300}

[ ]:

0.3 Question
With a given integral number n, write a program to generate a dictionary that contains (i, i*i) so
that is an integral number between 1 and n (both included). Then the program should print the
dictionary. Suppose the following input is supplied to the program: 8. Then, the output should
be: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}

[ ]:

0.4 Question
Write a Python program to create a set.
Examples : {0, 1, 2, 3, 4}
Write a Python program to iterate over sets.
Write a Python program to add members in a set and to remove items from a given set.

1
[ ]:

You might also like