0% found this document useful (0 votes)
4 views

Python Session Questions 2

Uploaded by

gagotiasushant
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Python Session Questions 2

Uploaded by

gagotiasushant
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Ques 1 - Write a Python function to calculate the sum of all elements in a list numbers.

Ques 2 - Write a Python function to count the number of occurrences of a given element in a list.
Case 1
Input
my_list = [1, 2, 3, 4, 2, 2, 5, 6, 2]
element_to_count = 2

Ques 3 - Write a Python function to find the common elements between two lists.
Case 1
Input
L1 =[ 23,56,78,90,34]
L2 = [78,10,2,3,45,234]
Output
78

Ques 4 - Write a Python program to check if a list is a palindrome (reads the same forward and
backward).

Case 1
Input
list1 = [1, 2, 3, 2, 1]
Output
True

Ques 5 - write a program to remove all occurrences of a specific item from a list.
Case 1
Input
list1 = [5, 20, 15, 20, 25, 15, 15] , item =15
Output
[5,20,20,25]

Ques 6 -Write a program to print a list after performing running sum on it.
Case 1
Input
list1 = [1,2,3,4,5,6]

Output
[1,3,6,10,15,21]

Ques 7 - Write a program that can find the max number of each row of a matrix.
Case 1
Input
[[1,2,3],[4,5,6],[7,8,9]]

Output
[3,6,9]

Ques 8 - Write a Python function to remove all duplicate characters from a given string and return the
result.
Input: "banana" Expected Output: "ban"
Ques 9 - Write a function that takes a string as input containing a combination of lowercase and
uppercase letters. It arranges the characters of the string so that all lowercase letters come first.

Input
"aBcDeFgHiJkLmNoPqRsTuVwXyZ"
Output
“acegikmoqsuwyBDFHJLNPRTVXZ”

Ques 10 - Write a Python function that accepts a string and calculate the number of upper case letters
Sample String : 'Digikull is an Education pLatfoRm fOr EveRy student.'
Expected Output :
7

You might also like