# Class 12 Python Data Structure Solved Practice Questions

Share with others

## Python Data Structure Practice Questions – Test 1

Q1. What do you mean by data structure?

Q2. Name any one linear data structure in python.

Q3. Python list are ______________ in Nature (static/dynamic)

Q4. “Lists are dynamic in nature” What do you mean by this statement?

Q5. What do you mean by Stack?

Q6. Name the end where we add or remove element in stack.

Q7. What is the full form of LIFO?

Q8. Give two example of stack from daily life.

Q9. Name two operations performed in stack.

Q10. What is the order of inserting elements in the following stack? Click for Data Structure Handout

## Python Data Structure Practice Questions – Test 2

Q1. Organization of data in python means ______.

Q2. Write the full form of the following:
a. LIFO
b. FIFO

```Show AnswerAns.
a. LIFO : Last In First Out
b. FIFO : First In First Out```

Q3. Which data structure is represented as FIFO?

Q4. Insertion into stack is called ______ (push/pop)

Q5. Giving printing command to printer is an example of _____     (stack/queue)

Q6. Reversing a number or a word/string is an example of     ______(stack or queue)

Q7. In stack addition or removal of elements takes place at ___     (one/both) end of the list.

Q8. In queue, addition of elements take place at one end and  removal of elements takes place at other end. (T/F)

Q9. If the elements “A”, “B”, “C” are added in the queue in the     following order,
first A then B and in last C.
In what order, it will come out of queue?

Q10. _________ function is used to add an  element in stack.

Click for Data Structure Handout

## Python Data Structure Practice Questions – Test 3

```Q1. Write a function Push() which takes number as argument and add in a stack "MyValue"
MyValue=[]
def Push(value):
MyValue.append(value)

Q2. Write a function Push that takes "name" as argument and add in a stack named "MyStack"
Mynames=[]
def Push(Value):
Mynames.append(Value)
Push("Amit")

Q3. Write a function Push() which takes "name" as argument and add in a stack named
"MyStack". After calling push() three times, a message should be displayed "Stack is
Full"
Ans.
MyStack=[]
StackSize=3
def Push(Value):
if len(MyStack) < StackSize:
MyStack.append(Value)
else:
print("Stack is full!")

Q4. Write a function pop() which remove name from stack named "MyStack".
def Pop(MyStack):
if len(MyStack) > 0:
MyStack.pop()
else:
print("Stack is empty.")

Q5. Write push(rollno) and pop() method in python:
push(rollno) --add roll number in Stack
pop() --- remove roll number from Stack.

MyStack=[]
def Push(rollno):
MyStack.append(rollno)
def Pop(MyStack):
if len(MyStack) > 0:
MyStack.pop()
else:
print("Stack is empty.")

Q6. Write add(bookname) and delete() method in python to add bookname and remove
bookname considering them to act as push() and pop() operations in stack.

MyStack=[]
MyStack.append(bname)
def delete(MyStack):
if len(MyStack) > 0:
MyStack.pop()
else:
print("Stack is empty. There is no book name")

Q7. Write addclient(clientname) and remove() methods in python to add new client and
delete existing client from a list "clientdetail", considering them to act as push and pop
operations of the stack.

clientdetail=[]
clientdetail.append(cn)
def remove():
if len(clientdetail)>0:
clientdetail.pop()
else:
print("Stack is empty")```

Click for Data Structure Handout

Class 12 Computer Science Sample Paper 2020-2021.

Class 12 Computer Science Sample Paper Marking Scheme

Class 12 Computer Science Test Series

Share with others
error: Content is protected !!