0% found this document useful (0 votes)
29 views17 pages

Python Class XII Competency Questions

Uploaded by

sudhirmohanpolie
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)
29 views17 pages

Python Class XII Competency Questions

Uploaded by

sudhirmohanpolie
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

Sample/Competency Based Questions (2025-26)

Computer Science
Class - XII

PYTHON REVISION TOUR-1


1 Mark
1. Consider the given expression:
"CBP" and not 70 or True and "ODISHA"
Which of the following will be correct output if the given expression is evaluated?
(a) True (b) False (c) ‘CBP’ (d) ‘ODISHA’
2. What is the output of the following?
if 0 or 0:
print('hello')
else:
print('Bye')
(a) bye (b) Hello (c) Bye (d) Nothing is printed

3. Identify an invalid identifier:


a) Out5 b) _Raath c) Sum*3 d) Ci12_1q
4. Predict the correct output of the code given below:
a=25
b=2.0
c=2
a//=2+c-1
b+=a+20
c=b//4
print(a,b,c,sep='%')
a) 8.0%30%7.0 b) 8%30.0%7.0
c) 8%25.0%5.0 d) 8.0%30.0%7
5. The continue statement is used:
a) To pass the control to the next iterative statement
b) To come out from the iteration
c) To break the execution and passes the control to else statement
d) To terminate the loop
6. What is the purpose of the pass statement in Python?
a) To terminate the loop
b) To skip the current iteration
c) To define an empty function or class
d) To comment out code
7. What is the output of following statement?
print(8 and 0).
a) 8 b) 0 c) True d) False
8. What will be the value of the expression?
13+14%15
a) 13
b) 12
c) 0
d) 27
9. Predict the output of the following Code.
for x in '23lamp':
print([Link](),end='')
a) 23LAMP
b) 23Lamp
c) 2 3 L A M P
d) 2 3 L a m p
10. What will be the output of this code?
x = [1, 2, 3]
y = x[:]
y[0] = 99
print(x)
a) [1,2,3] b) [99,2,3] c) [0,1,2,3] d) Error will occur

2 Marks
1. What is the output produced by the following code?
x=1
if x < 3:
if x > 4:
print ("A", end = ' ')
else :
print ("B", end = ' ')
elif x > 2:
if (x != 0) :
print ("C", end = ' ')
print ("D")
2. Rewrite the following Python program after removing any/all logical and syntax error(s), underline
each correction done in the code:
A = input("Enter First Number: ")
B = int(input("Enter Second Number: "))
Op = input("Enter Operator:")
if Op = "+":
C =A+ B
elseif Op == "-":
C =A- B
else
C = "Invalid operator entered"
Print ("Result = ", C)
3. Write the output of following code:
for i in range(1,5):
for j in range(2,i+2):
print('@',end=' ')
print()
4. Find out the output.
X,Y,Z=10,8,12
X,Y,Z=X+Y,Y+Z,X+Y+Z
Print(X, Y, Z)
5. Give the output of the following expressions:
(a) res=3**1**3**1 (b) res=15//2//3
(c) res=not 15 and 15 or not 15 and 15 or 15
(d) res=(90%4)> 12 or not (20//2) < 8 and (60//3) >= 4
6. What is implicit and explicit type casting and explain with an appropriate example.
7. What is dynamic typing in python?
8. Draw a Logic Diagram of given Boolean Expression.
F(X,Y,Z) = ((X’+Y).(X+Y’+Z))’
9. What are the Functions of an Operating system?
10. Convert the following number in to given numbers:
a) (345.24)10 =( )2 b) (A35.57)16 =( )8

3 Marks
1. Write a program to print the following pattern:
12345
1234
123
12
1
2. What will be the output of the Python code given below if value of:
i. n=3.0
ii. n=-3
iii. n=0
n=int(input("enter the value of n:"))
sum=0
if n<0:
for i in range(2*n,n+1):
sum+=i
else:
for i in range(n,2*n+1):
sum+=i
print("SUM=",sum)
3. Write a program to print monthly telephone bill. Calculate the bill based on the following criteria.
Number of calls Price per call
Upto 100 0.00
> 100 6.50
> 500 7.50
>1000 8.50
Instructions: If the number of calls is 250 then no charges for first 100 calls and remaining 150 calls will
be charged as 6.50
4. a. How many times the values of i and j will be displayed after executing the
following python code?
i,j=5,6
while i<20:
i=i+j
j=j-1
print(i,j)
b. Rewrite the following for loop into its equivalent while loop
for i in "Programming ":
print(i)
5. Write a Python code to input electricity unit charges and calculate total electricity bill according to
given condition:
For units between 0-49, charge is Rs 0.50/unit.
For units between 50-99, charge is Rs 0.75/unit.
For units between 100-199, charge is Rs 1.20/unit.
For 200 and above units, charge is Rs 1.50/unit.
An additional surcharge of 20% is added to the bill in each case.
6. Write the difference between mutable and immutable data types in python.
7. Explain the main components of computer system with block diagram ?
8. There are two types of else clauses in Python. What are these two types of else clauses?
9. Rewrite the following code in Python after removing all syntax error(s). Underline each correction
done in the code.

Value = 30
for VAL in range(0, Value)
If val % 4 == 0:
print (VAL *4)
Elseif val % 5 == 0:
print (VAL + 3)
else
print(VAL + 10)

10. Write any three differences between a list and a tuple in Python.
Python Revision Tour-II
1 Mark

[Link] of the following methods is not applicable to a tuple?


A) count() B) append() C) index() D) len()
2. Write the output of the given Python code.

list1 = [‘physics’, ‘chemistry’, 1997, 2000];


list2 = [1,2,3,4,5,6, 7];
print “list1[0]”, list1[0]

3. Write Python code to reverse a string using slicing.


4. Write the output of the given Python code.

listl = [‘physics’, ‘chemistry’, 1997,2000];


list2 = [1,2, 3,4,5, 6, 7];
print “list2[l:5[ :”, list2[l:5]
5. Which statement is true about Python lists?
A) Elements must be of the same type B) Lists are immutable
C) Lists are ordered and mutable D) Lists are unordered
6. Which function is use for comparing elements of both tuples.

7. Which operation is valid for both lists and tuples?


A) append() B) insert() C) count() D) pop()
8. Which function gives the total length of the tuple
9. How can you retrieve all the keys from a dictionary named d?
10. Write a program to print the worker’s information (Name age, salary) in records format

2 Marks
1. Write the difference between list and tuple?
2. Give an example to remove list element
3. Find the errors from the following code?
Str= “Welcome
Note “ ”
for s in range (0,8)
print(String(s))
4. Write the output of the given python code:
list1, list2 = [123, ‘xyz’], [456, ‘abc’]
print cmpt(list1, list2);
print cmp(list2, list1);
list3 = list2 + [786];
print cmp(list2, list3)
5. Write the output of the following code.
T=tuple()
T=t+(‘Python’,)
print(T)
print(len (T))
6. Write the output of the given python code:
tuple1, tuple2 = (123, ‘xyz’), (456, ‘abc’)
print cmp (tuple1, tuple2) ;
print cmp (tuple2, tuple1) ;
tuple3 = tuple2 + (786,);
print cmp (tuple2, tuple3)

7. Write the output of the following code.


lst=[10,12,14,20,22,24,30,32,34]
seq1=lst[3:-3]
print(seq1)
seq2=lst[2:10:3]
print(seq2)
8. What is a key-value pair with reference to Python dictionary?
9. How are elements accessed from a dictionary? Illustrate with an example
10. What will be the output of the following code
Values [ ]
for i in range(1,4) :
[Link](i)
print(values)
3 Marks
1. T = (10, 20, [30, 40])
a) Can we do T[1] = 25?
b) Can we do T[2][0] = 35? Explain.
2. Write the output of the given Python code:

aList = [123, ‘xyz’, ‘zara’, ‘abc’, 123];


bList = [2009, ‘manni’];
[Link] (bList)
print “Extended List :”, aList;
3. Write the difference between list and dictionary?
4. Write the output of the given python code:

aList = [123, ‘xyz’, ‘zara’, ‘abc’];


[Link] (3,2009) print “Final List:”, aList
5. fruit ={}
f1=[‘Apple’,’Banana’,’apple’,’Banana’]
for index in f1:
if index in fruit :
fruit[index]+=1
else:
fruit[index]=1
print(fruit)
6. Write a program to input n x m matrix and find the sum of all numbers

7. Store 3 students’ marks in a dictionary. Find the name(s) with the highest marks.

8. Write the output for the following codes.


A= (10:1000,20:2000,30:3000,40:4000, 50:5000}
print [Link]()
print [Link]()
print [Link]()
9. Program to input 5 numbers, remove even numbers, and display the list.
10. Write the output of the given python code:

tuple1, tuple2 = (123, ‘xyz’, ‘zara’, ‘abc’), (456, 700, 200)


print “min value element : “, min (tuple1);
print “min value element : “, min (tuple2);
Working with Functions
1 Mark
Q1. Consider the statements given below and then choose the correct output from the given option:
def test(x, y=[]):
[Link](x)
return y
print(test(1))
print(test(2, []))
print(test(3))
A. [1] [2] [3] B. [1] [1, 2] [1, 2, 3]
C. [1] [2] [1, 3] D. [1] [2] [1, 3]
Q2. Consider the statements given below and then choose the correct output from the given option:
def say(msg, times=2):
print(msg * times)
say("Hello")
say("Hi", 3)
A. HelloHello and HiHiHi B. Hello and HiHiHi
C. HelloHello and Hi D. Error
Q3. Consider the statements given below and then choose the correct output from the given option:
def update(item):
item += [10]
a = [1, 2]
update(a)
print(a)
A. [1, 2] B. [1, 2, 10]
C. 10 D. Error
Q4. Consider the statements given below and then choose the correct output from the given option:
def calc(x, y):
x=x+y
y=x-y
x=x-y
return x, y
a, b = calc(10, 5)
print(a, b)
A. 5 10 B. 10 5
C. 15 0 D. 5 5
Q5. Consider the statements given below and then choose the correct output from the given option:
def func(a, b):
return [a + b, a - b]
print(func(5, 2)[1])
A. 7 B. 3
C. [7, 3] D. 2

2 Marks
Q6. What is the difference between print () and return in functions? Explain with the help of an
example.
Q7. What is a function with multiple return values? Give an example.
Q8. Can we pass a function as an argument to another function? Give example.
Q9. What is the use of global keyword in functions? Give an example.
Q10. Explain the difference between None and 0 as return values in functions.

Q11. Observe the following code carefully and rewrite it after removing all syntax and logical errors.
Underline
all the corrections made:
def is_palindrome(str):
rev = str[::1]
if rev = str:
return True
else:
return false

print(is_palindrome("madam"))

3 Marks
Q12. Predict the output of following code:
def calc(a, b):
a=a+2
b=b+3
print("Inside:", a, b)
return a + b
x=1
y=2
z = calc(x, y)
print("Outside:", x, y)
print("Sum:", z)
Q13. Predict the output of following code:
def count(n):
if n <= 0:
return
print(n)
count(n - 1)
print(n)
count(3)
Q14. Predict the output of following code:
def mix_strings(a, b):
return a[:2] + b[-2:] + a[-1]
print(mix_strings("Hello", "World"))
Q15. Predict the output of following code:
def alternate_case(s):
new = ""
for i in range(len(s)):
if i % 2 == 0:
new += s[i].upper()
else:
new += s[i].lower()
return new
print(alternate_case("python"))

Q16. Predict the output of following code:


def add_subject(student, subject):
if subject not in student["subjects"]:
student["subjects"].append(subject)
return student

data = {"name": "Priya", "subjects": ["Math", "English"]}


print(add_subject(data, "Biology"))
print(add_subject(data, "Math"))
DATA FILE HANDLING
3 MARKS :
1. Write a function countEU( ) in Python, which should read each character from a text file [Link]
, count and display occurrence of alphabets E and U ( including small cases e and u too).
e.g. If the file content is as follows:
Pinky has gone to her friend’s house.
Her friend name is [Link] house is 12 km away from Pinky house.
The countEU( ) function should display the output as
E or e : 8
U or u :3
2. (a) Differentiate between text file and binary file.
(b) Write a Python function that finds and displays all the words longer than 5 characters
from a text file "[Link]".
3. A binary file “[Link]” has structure (admission_number, Name, Percentage). Write a
function countrec() in Python that would read contents of the file “[Link]” and display the
names of those students whose percentage is 75 or more but less than 80. Also display number of
students scoring this.
4. Sangeeta is a Python programmer working in a computer hardware company. She has to maintain
the records of the peripheral devices. She created a csv file named [Link], to store the
details. The structure of [Link] is:
[P_id, P_name, Price] where
P_id is Peripheral device ID (integer)
P_name is Peripheral device name (String)
Price is Peripheral device price (integer)
Sangeeta wants to write the following user defined functions:
Add Device(): to accept a record from the user and add it to a csv file, [Link].
Count_Device(): To count and display number of peripheral devices whose price is less than 1000.
5. Mahesh is a Python programmer working in a school. For the Annual Sports Event, he has created
a csv file named [Link], to store the results of students in different sports events. The structure
of [Link] is :[St_Id, St_Name, Game_Name, Result]
Where
St_Id is Student ID (integer)
ST_name is Student Name (string)
Game_Name is name of game in which student is participating(string)
Result is result of the game whose value can be either 'Won', 'Lost' or 'Tie'.
For efficiently maintaining data of the event, Mahesh wants to write the following user defined
functions:
Accept() – to accept a record from the user and add it to the file [Link]. The column headings
should also be added on top of the csv file.
wonCount() – to count the number of students who have won any event.
6. Write the definition of a Python function named LongLines ( ) which reads the contents of a text
file named '[Link]' and displays those lines from the file which have at least 10 words in it.
For example, if the content of '[Link]' is as follows:
Once upon a time, there was a woodcutter
He lived in a little house in a beautiful, green wood.
One day, he was merrily chopping some wood.
He saw a little girl skipping through the woods, whistling happily.
The girl was followed by a big gray wolf.
Then the function should display output as :
He lived in a little house in a beautiful, green wood.
He saw a little girl skipping through the woods, whistling happily.
7. Write a function count_Dwords () in Python to count the words ending with a digit in a text file
"[Link]".
Example:
If the file content is as follows:
On seat2 VIP1 will sit and
On seat1 VVIP2 will be sitting
Output will be:
Number of words ending with a digit are 4
8. (a) Write one difference between Seek( ) and tell( ) .
(b) Write a program in Python that defines and calls the following user defined functions:
Add_Book() Takes the details of the books and adds them to a csv file '[Link]'. Each record
consists of a list with field elements as book_ID, B_name and pub to store book ID, book name
and publisher respectively.
Search Book(): Takes publisher name as input and counts and displays number of books
published by them.
9. Saswat is a Python programmer. He created a binary file [Link] with employeeid, ename and
salary. The file contains 10 records. He now has to update a record based on the employee id
entered by the user and update the salary. The updated record is then to be written in the file
[Link]. The records which are not to be updated also have to be written to the file [Link]. If
the employee id is not found, an appropriate message should to be displayed. As a Python expert,
help him to complete the following code based on the requirement given above:
import _______ #Statement 1
def update_data():
rec={}
fin=open("[Link]","rb")
fout=open(_____________) #Statement 2
found=False
eid=int(input("Enter employee id to update their salary :: "))
while True:
try:
rec=______________ #Statement 3
if rec[0]==eid:
found=True
rec[2]=int(input("Enter new salary :: "))
pickle.____________ #Statement 4
else:
[Link](rec,fout)
except:
break
if found==True:
print("The salary of employee id ",eid," has been updated.")
else:
print("No employee with such id is not found")
[Link]()
[Link]()
(i) Which module should be imported in the program? (Statement 1)
(ii) Write the correct statement required to open a temporary file named [Link].
(Statement 2)
(iii) Which statement should Abhay fill in Statement 3 to read the data from the binary
file, [Link] and in Statement 4 to write the updated data in the file, [Link] ?
10. Write a function Start_with_I() in Python, which should read a text file '[Link]' and then display
lines starting with 'I'. Example: If the file content is as follows:
Gratitude is a humble heart's radiant glow,
A timeless gift that nurtures and bestows.
It's the appreciation for the love we're shown,
In moments big and small, it's truly known.
Then the output should be :
It's the appreciation for the love we're shown,
In moments big and small, it's truly known.

2 MARKS
1. In the following questions, a statement of Assertion (A) is followed by a statement of Reason (R).
Mark the correct choice as :
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not the correct explanation of A
(c) A is true but R is false
(d) A is false but R is true.
(i) Assertion (A): If numeric data are to be written to a text file, the data needs to be converted into
a string before writing to the file.
Reason (R):write() method takes a string as an argument and writes it to the text file.
(ii) Assertion (A): CSV file is a human readable text file where each line has a number of fields,
separated by comma or some other delimiter.
Reason (R): writerow() method is used to write a single row in a CSV file.

2. Consider the file '[Link]' given below .What output will be produced by following code
fragment?
God made the Earth.
Man made confusing countries.
And their fancy-frozen boundaries.
But with unfound boundless Love

obj1 = open('[Link]', 'r')


s1= [Link]()
s = [Link](10)
print(s)
s3 = [Link](19)
print(s3)
print([Link]())
[Link]()
3. Observe the following Python code and fill in the blanks with appropriate statements to read a
CSV file named [Link] and print its content.
import csv
with ___________as f: #statement1
r = csv.________(f) #statement2
for row in __________ : #statement3
print( ____ ) #statement4
4. Write a Python program that copies the contents of a text file named [Link] to another file
named [Link], excluding all lines that start with the @ symbol.
5. Write a function in Python to read a text file, “[Link]” and displays those lines which begin
with the word “You”.
6. Write a function to copy all 5 and 7 letter words of a text file “[Link]” to another file “[Link]”.
7. (a) Write appropriate statement for the following missing statement to get the output as:-
‘consists of going from failure to failure without loss of enthusiasm’
f=open('[Link]','w+')
[Link]('Success consists of going from failure to failure without loss of enthusiasm')
______________
print([Link]())
[Link]()
(a) [Link](8,2-2) (b) [Link](8,0) (c) [Link](8) (d) All of the above.
(b) Write the missing statement to complete the following code:
f=open("[Link]","w+")
[Link]("DAV Pre Board 2025") ______________ # Move the file pointer to the
third character from end
print([Link](2))
8. A text file “[Link]” contains some text, which needs to be displayed such that every next
character is separated by a symbol “#”. Write a function definition for hash_display() to display
the entire content of the file “[Link]” in the desired format. Consider the file “[Link]” :

THE WORLD IS ROUND


The hash_display() function should display the following content:
T#H#E# #W#O#R#L#D# #I#S# #R#O#U#N#D#
9. Write a function CountVowelConso() which will calculate the total number of occurrence of
vowels and consonants in a text file ‘[Link]’. For example, if the content of [Link] is: -
I like Python Programming
Then the output should be: -
Total vowels=7
Total consonant=15
10. Write a function RevText() to read a text file “ [Link] “ and Print the word(s) starting with ‘I’ in
reverse order, rest of the words will be printed as it is.
Example: If content of the text file is:
INDIA IS MY COUNTRY
Output will be: AIDNI SI MY COUNTRY

DATA STRUCTURE
1 Marks
1. In Stack Insertion and deletion of an element is done at single end called ________
a. Start
b. Last
c. Top
d. Bottom

2. In a stack, if a user tries to remove an element from empty stack it is called _________
a. Underflow
b. Empty
c. Overflow
d. Garbage Collection

3. If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, in what
order will they be removed?
a. ABCD
b. DCBA
c. DCAB
d. ABDC

4. Which of the following data structure is linear type?


a. Stack
b. Array
c. Queue
d. All of the above

5. Which of the following statement(s) about stack data structure is/are NOT correct?
a. Stack data structure can be implemented using linked list
b. New node can only be added at the top of the stack
c. Stack is the FIFO data structure
d. The last node at the bottom of the stack has a NULL link

1. In a stack, if a user tries to remove an element from empty stack it is called _________

a. Underflow
b. Empty
c. Overflow
d. Garbage Collection

7. While implementing Stack using list when we want to delete element we must use pop function
as_____
a. [Link](pos)
b. [Link](0)
c. [Link]()
d. [Link]()
8. The process of visiting each element in any Data structure is termed as ____________
a. Visiting
b. Searching
c. Traversing
d. Movement

9 In stack we cannot insert an element in between the elements that are already inserted.
a. True
b. False

10. Python built-in data structures are


a. integer, float, string
b. list, tuple, dictionary, set
c. math, pyplot
d. all of the above

2 Marks

1. “Stack is a linear data structure which follows a particular order in which the operations are
performed.”
What is the order in which the operations are performed in a Stack?
Name the List method/function available in Python which is used to remove the last element from a
list implemented stack.
Also write an example using Python statements for removing the last element of the list.
2. Python statement for removing the last element from of the list:

3. What are Application of Stack?

4. What is a stack ? what basic operation can be performed on them?


5. Differentiate between Stack Overflow and Stack Underflow.

6. What do you meant by LIFO structure? Support your answer with real life example.
7. What is the different types data structure? Give an example of each type.

8. What are underflow and overflow condition in a stack?

9. How can a list be used to implement a stack in Python? Provide an example.

10. Given the following code, what is the output?


stack = []
[Link](1)
[Link](2)
print(stack[-1])

11. Write a Python function using a list to check if a stack is empty.

12. Write a Python code to implement a stack using a list and show push and pop operations.
3 Marks

1. Consider a list named Nums which contains random integers.


Write the following user defined functions in Python and perform the specified operations on a stack
named BigNums.
i. PushBig(): It checks every number from the list Nums and pushes all such numbers which have 5
or more digits into the stack, BigNums.
ii. PopBig(): It pops the numbers from the stack, BigNums and displays them. The function should
also display "Stack Empty" when there are no more numbers left in the stack.
For example: If the list Nums contains the following data:
Nums = [213, 10025, 167, 254923, 14, 1297653, 31498, 386, 92765]
Then on execution of PushBig(), the stack BigNums should store:
[10025, 254923, 1297653, 31498, 92765]
And on execution of PopBig(), the following output should be displayed:
92765
31498
1297653
254923
10025
Stack Empty
2. 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

3. Write a function in python, MakePush(Package) and MakePop(Package) to add a new Package and
delete a Package from a List of Package Description, considering them to act as push and pop
operations of the Stack data structure.

4. Write a function in Python PUSH(Arr), where Arr is a list of numbers. From this list push all numbers
divisible by 5 into a stack implemented by using a list. Display the stack if it has at least one element,
otherwise display appropriate error message.
5. Write a function in Python POP(Arr), where Arr is a stack implemented by a list of numbers. The
function returns the value deleted from the stack.
6. A list contains following record of a customer:
[Customer_name, Phone_number, City]
Write the following user defined functions to perform given operations
on the stack named ‘status’:
(i) Push_element() - To Push an object containing name and
Phone number of customers who live in Goa to the stack
(ii) Pop_element() - To Pop the objects from the stack and
display them. Also, display “Stack Empty” when there are no
elements in the stack.

For example:

If the lists of customer details are:

[“Gurdas”, “99999999999”,”Goa”]
[“Julee”, “8888888888”,”Mumbai”]
[“Murugan”,”77777777777”,”Cochin”]
[“Ashmit”, “1010101010”,”Goa”]

The stack should contain


[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]

The output should be:


[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
Stack Empty

7. Write a function in Python, Push(SItem) where , SItem is a dictionary containing the details of
stationary items– {Sname:price}. The function should push the names of those items in the stack who
have price greater than 75. Also display the count of elements pushed into the stack. For example: If the
dictionary contains the following data:
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}

8. A list contains following record of a customer: [Customer_name, Phone_number, City] Write the
following user defined functions to perform given operations on the stack named ‘status’:
(i) Push_element() - To Push an object containing name and Phone number of customers who
live in Goa to the stack
(ii) Pop_element() - To Pop the objects from the stack and display them. Also, display “Stack
Empty” when there are no elements in the stack.
For example:
If the lists of customer details are:
[“Gurdas”, “99999999999”,”Goa”]
[“Julee”, “8888888888”,”Mumbai”]
[“Murugan”,”77777777777”,”Cochin”]
[“Ashmit”, “1010101010”,”Goa”]
The stack should contain
[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
The output should be:
[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
Stack Empty

9. Write a function in Python, Push(SItem) where , SItem is a dictionary containing the details of
stationary
items– {Sname:price}.
The function should push the names of those items in the stack who have price greater than 75. Also
display the count of elements pushed into the stack.
For example:
If the dictionary contains the following data:
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}
The stack should contain
Notebook
Pen
The output should be:
The count of elements in the stack is 2

1. Write a function in python named PUSH(STACK, SET) where STACK is list of some numbers
forming a stack and SET is a list of some numbers. The function will push all the EVEN elements
from the SET into a STACK implemented by using a list. Display the stack after push operation.

2. Write a function in python named POP(STACK) where STACK is a stack implemented by a list of
numbers. The function will display the popped element after function call.

You might also like