P2 SET2 Question PP 2022-23

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

K. J.

Somaiya College of Engineering, Mumbai-77


(A Constituent College of Somaiya Vidyavihar University)

Course: PYTHON PROGRAMING Semester: SECOND

Division: P2 Batch: Date: 27/04/2023

Exam: ON SCREEN TEST Time: 1:15 PM to 3:15 PM

Name: Roll No:

SET 2

Q No Question Marks

1 Attempt any one 8

a) Write a Python program to count the positive, negative and zero numbers from a
list.

Test Case 1: Test Case 2: Test Case 3:


Given x = [23, 4, -6, 23, Given x = [23, 4, 23, Given x = [23, 4, -6, 23,
-9, 21,0, 3, -45, 0,-8] 21,0, 3, 0] -9, 21, 3, -45, -8]
Result: Result: Result:
Positive: 5 Positive: 5 Positive: 5
Negative: 4 Negative: 0 Negative: 4
Zero: 2 Zero: 2 Zero: 0

b) Write a Python program to find all three and/or four character words which end
with vowels in a string.

Test Case 1: Test Case 2:


Input: “The quick brown fox jumps Input: “The little bird flew across the
over the laze dog in an ice.” blue sky and landed on the soft green
Output: grass.”
[‘The’, ‘the’, ‘laze’ ,‘ice’] Output:
[‘The’, ‘blue’, ‘the’]
\

2 Attempt any one 12

a) Write a Python program that takes two tuples test_tuple1 and test_tuple2 and
returns a list of all pair combinations of the two tuples.
K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)

Test Case 1: Test Case 2: Test Case 3:


Input: test_tuple1(7,2) Input: test_tuple1(4,5,6) Input: test_tuple1(4,5,6)
test_tuple2(7,8) test_tuple2(7,8) test_tuple2(2,3,4)
Output : Output : Output :
[(7,7),(7,8),(2,7),(2,8),(7, [(4, 7), (4, 8), (5, 7), (5, [(4, 2), (4, 3), (4, 4), (5,
7),(7,2),(8,2)] 8), (6, 7), (6, 8), (7, 4), 2), (5, 3), (5, 4), (6, 2),
(7, 5), (7, 6), (8, 4), (8, (6, 3), (6, 4), (2, 4), (2,
5), (8, 6)] 5), (2, 6), (3, 4), (3, 5),
(3, 6), (4, 4), (4, 5), (4,
6)]

b) Write a Python program that takes two lists, lst_1 and lst_2 as input and performs
the following using lambda and filter functions:
i) Intersection of the two lists
ii) lst_1 - lst_2 (Elements present in lst_1 but not in lst_2 without any
duplicates)
iii) lst_2 - lst_1 (Elements present in lst_2 but not in lst_1 without any
duplicates)
iv) Union of the two lists

Test Case 1: Test Case 2:


lst_1 = [1,6,7,10,13,32] lst_1 = [1,6,7,10]
lst_2 = [13,17,18,32] lst_2 = [13,17,18,32]

Output: Output:
i) [13,32] i) []
ii) [1,6,7,10] ii) [1,6,7,10]
iii) [17,18] iii) [13,17,18,32]
iv) [1,6,7,10,13,32,17,18] iv) [1,6,7,10,13,17,18,32]

You might also like