0% found this document useful (0 votes)
10 views5 pages

Combine PDF

This document contains questions and answers related to Python data structures. [Q2.] Name any one linear data structure in python. [A.] List [Q3.] Python list are ______________ in Nature (static/dynamic) [A.] Dynamic [Q4.] “Lists are dynamic in nature” What do you mean by this statement? [A.] This means that list can be grown or shrink in size means elements can be deleted or added in list.

Uploaded by

Muhammed Nehan
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)
10 views5 pages

Combine PDF

This document contains questions and answers related to Python data structures. [Q2.] Name any one linear data structure in python. [A.] List [Q3.] Python list are ______________ in Nature (static/dynamic) [A.] Dynamic [Q4.] “Lists are dynamic in nature” What do you mean by this statement? [A.] This means that list can be grown or shrink in size means elements can be deleted or added in list.

Uploaded by

Muhammed Nehan
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/ 5

Q2.

Q4
Q3 .
.
Python Data Structure Practice Questions –
Test 1
Q1. What do you mean by data structure?
Ans . A data structure is a way of storing, organizing and retrieving data in a
computer.
Q2. Name any one linear data structure in python.
Ans . List
Q3. Python list are ______________ in Nature (static/dynamic)
Ans. Dynamic
Q4. “Lists are dynamic in nature” What do you mean by this statement?
Ans. This means that list can be grown or shrink in size means elements can
be deleted or added in list.
Q5. What do you mean by Stack?
Ans. A stack is a linear data structure where elements can be inserted or
deleted at one end.
Q6. Name the end where we add or remove element in stack.
Ans. Top
Q7. What is the full form of LIFO?
Ans. Last In First Out
Q8. Give two example of stack from daily life.
Ans. A pile of book, a stack of carom coins etc.
Q9. Name two operations performed in stack.
Ans. Push and Pop
Q10. What is the order of inserting elements in the following stack?

Ans. Order is: A, B, C, D


Python Data Structure Practice Questions – Ans. A, B, C

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


Ans. Push/ append()
Q1. Organization of data in python means ______.
Ans. Data Structure Q1. Write a function Push() which takes number as argument and add in a
stack "MyValue"
Q2. Write the full form of the following: Ans.
a. LIFO MyValue=[]
b. FIFO def Push(value):
Ans. a. LIFO : Last In First Out b. FIFO : First In First Out MyValue.append(value)

Q3. Which data structure is represented as FIFO?


Ans. Queue Q2. Write a function Push that takes "name" as argument and add in a stack
named "MyStack"
Q4. Insertion into stack is called ______ (push/pop) Ans
Ans. Pop Mynames=[]
def Push(Value):
Q5. Giving printing command to printer is an example of Mynames.append(Value)
Push("Amit")
_____ (stack/queue)
Ans. Queue
Q3. Write a function Push() which takes "name" as argument and add in a
Q6. Reversing a number or a word/string is an example of ______(stack stack named
or queue) "MyStack". After calling push() three times, a message should be displayed
Ans. Stack "Stack is
Full"
Q7. In stack addition or removal of elements takes place at ___ (one/both)
Ans.
end of the list. MyStack=[]
Ans. One StackSize=3
def Push(Value):
Q8. In queue, addition of elements take place at one end and removal if len(MyStack) < StackSize:
of elements takes place at other end. (T/F) MyStack.append(Value)
Ans. True else:
print("Stack is full!")
Q9. If the elements “A”, “B”, “C” are added in the queue in
the following order, Q4. Write a function pop() which remove name from stack named "MyStack".
first A then B and in last C. Ans.
In what order, it will come out of queue?
def Pop(MyStack):
if len(MyStack) > 0: Ans.
MyStack.pop() clientdetail=[]
else: def addclient(cn):
print("Stack is empty.") clientdetail.append(cn)
def remove():
if len(clientdetail)>0:
Q5. Write push(rollno) and pop() method in python: clientdetail.pop()
push(rollno) --add roll number in Stack else:
pop() --- remove roll number from Stack. print("Stack is empty")

Ans.
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.

Ans.
MyStack=[]
def add(bname):
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.

You might also like