Revision Test Series - 3: Computer Science
Revision Test Series - 3: Computer Science
1
SECTION B- VERY SHORT ANSWER QUESTIONS
9 Write a python statements for the following 2
a) Define stack student as a list of 5 student names
b) To remove the last element from a stack student using suitable
method/function.
10 Convert the following infix expression into its equivalent postfix 2
expression using stack and show the contents of stack after execution
of each operation
( ( A – B ) * ( D / E ) )/ ( F * G * H )
OR
Evaluate the following postfix notation of expression: (Show status of
stack after each operation.
True, False, NOT, OR, False, True, OR, AND
11 Give any two characteristics of stacks. 2
12 KV is making the data base of students for that data is stored in list 2
stack
form but the code is not complete , complete the code as per
your
knowledge and make the software run:
std=[ ]
def push(std):
n=int(input(“name of student”)
r=int(input(“rollnoof student”)
c=int(input(“class”))
__________________ #statement 1
std.append(temp)
def pop(std):
______________ # statement 2
print(“No Record”)
else:
print(“Deleted Record is “, std.pop())
2
For example:
If the sample content of the dictionary is as follows:
T={“Chennai Super “:76, “Mumbai Indians”:87, “Royal
Challengers”:89,
“Kolkatta Knight Riders”:65, “Rajasthan Royals”:110,
“MasterBlasters”:106,
“Punjab Kings”:95 }
The output from the program should be:
Rajasthan Royals MasterBlasters
14 Write a function LShift(Arr,n) in Python, which accepts a list Arr of 3
numbers and n is no. of elements in Arr where all elements are shifted
to left and the first element will be placed atthe end of the list (3)
Sample Input Data of the list
Arr= [ 10,20,30,40,12,11]
Output
Arr = [20,30,40,12,11,10]
15 Create a csv file called ‘Groceries’ to store information of different 3
items existing in a shop. The information is to be stored with respect to
each item code, name, price, quantity. Write a function to accept the
data from user and store it permanently in csv file.
OR
Write a Python program that reads data from a CSV file named
"data.csv" using the csv.reader() object. For each row, if the value in
the second column (index 1) is greater than 50, write that row into a
new CSV file named "high_scores.csv" using the csv.writer() object.
SECTION D-LONG ANSWER QUESTIONS
16 A csv file "Happiness.csv" contains the data of a survey. Each record 5
of the file contains the following data: (4)
● Name of a country
● Population of the country
● Sample Size (Number of persons who participated in the
survey in that country)
● Happy (Number of persons who accepted that they were
Happy)
3
OR
Alam has a list containing 10 integers. You need to help him create a
program with separate user defined functions to perform the following
operations based on this list.(4)
● Traverse the content of the list and push the even numbers
into a stack.
● Pop and display the content of the stack.
For Example:
If the sample Content of the list is as follows: N=[12, 13,
34, 56, 21, 79, 98, 22, 35, 38] Sample Output of the code
should be: 38 22 98 56 34 12
SECTION E-CASE BASED QUESTIONS
17 Shantanu of class 12 is writing a program to create a CSV file (5) 5
“BoardDetails.csv” which will contain Board RollNo, StuName,
DateOfBirth for some entries. He haswritten the following code.
As a programmer, help him to successfully execute thegiven task.
defreadCsvFile():
f=open('BoardDetails.csv','__') #Line 3
y = csv._________ #Line 4
for row in y:
if (int(row[0])>9107750):
print(row[0],row[1])
f.close()
addCsvFile(9107752,"Sita Sharma","2003/10/21")
addCsvFile(9107751,"Gita Patel","2004/11/01")
addCsvFile(9107750,"Suresh Rao","2003/10/25")
readCsvFile()