You are on page 1of 1

Assignment 2

Name: Submission Date: 20-11-2023


Roll #: Marks: 25
1. Write a program that will take a number as input from user and find the sum of the digits in
the input number.
Hint: The input is 120 so the function will add the digits like 1+2+0 = 3 and return 3.
2. Write a program that will find the factorial of all the number in a list. You code should be
run any length of the list.
Input: [2, 4, 5, 6, 8, 9]
Output: [2, 24, 120, 720, 40320, 362880]
3. Write a program that will check the duplication in a list and it will return the list without
duplication.
Input: [6, 7, -2, 11, 7, -2]
Output: [6, 7, -2, 11]
4. Write a program that will take the parameters of a (number of rows and columns). It will
print the list which has rows and columns according to the given parameters and all the
elements will be zero.
Input: 3, 3
Output: [[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
5. You have to design a program that will take a 2D list and a number. Then it will multiple the
input number with each element of the list.

Input: [ [1, 2, 3] , [3, 1, 2], [0, 3,2] ] num = 5


Output: [ [5, 10, 15] ,
[15, 5, 10],
[0, 15, 10] ]

You might also like