Test Index

CBSE Class 12 Computer Science 2022 Paper 91 Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 8 of 13
Marks: +1, -0
• Write the definition of a user defined function PushNV(N) which accepts a list of strings in the parameter N and pushes all strings which have no vowels present in it, into a list named NoVowel.
• Write a program in Python to input 5 words and push them one by one into a list named All.
The program should then use the function PushNV() to create a stack of words in the list NoVowel so that it stores only those words which do not have any vowel present in it, from the list All. Thereafter, pop each word from the list NoVowel and display the popped word. When the stack is empty display the message "EmptyStack".
For example :
If the Words accepted and pushed into the list All are
['DRY', 'LIKE', 'RHYTHM', 'WORK', 'GYM']
Then the stack NoVowel should store
['DRY', 'RHYTHM', 'GYM']
And the output should be displayed as
GYM RHYTHM DRY EmptyStack
OR
• Write the definition of a user defined function Push3_5(N) which accepts a list of integers in a parameter N and pushes all those integers which are divisible by 3 or divisible by 5 from the list N into a list named Only3_5.
• Write a program in Python to input 5 integers into a list named NUM.
The program should then use the function Push3_5() to create the stack of the list Only3_5. Thereafter pop each integer from the list Only3_5 and display the popped value. When the list is empty, display the message "StackEmpty".
For example :
If the integers input into the list NUM are :
[10, 6, 14, 18, 30]
Then the stack Only3_5 should store
[10, 6, 18, 30]
And the output should be displayed as
30 18 6 10 StackEmpty
Advertisements
Go to Question: