[go: up one dir, main page]

0% found this document useful (0 votes)
162 views9 pages

Rev 1 CS

The document is the question paper for the Computer Science Revision Exam 1. It contains general instructions for the exam, which is divided into 5 sections (A to E). Section A contains 18 1-mark questions. Section B contains 7 2-mark questions. Section C contains 5 3-mark questions. Section D contains 2 4-mark questions. Section E contains 3 5-mark questions. All programming questions must be answered in Python. The document provides the framework and guidelines for the exam.

Uploaded by

sudhan sharvesh
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)
162 views9 pages

Rev 1 CS

The document is the question paper for the Computer Science Revision Exam 1. It contains general instructions for the exam, which is divided into 5 sections (A to E). Section A contains 18 1-mark questions. Section B contains 7 2-mark questions. Section C contains 5 3-mark questions. Section D contains 2 4-mark questions. Section E contains 3 5-mark questions. All programming questions must be answered in Python. The document provides the framework and guidelines for the exam.

Uploaded by

sudhan sharvesh
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/ 9

REVISION EXAM 1

COMPUTER SCIENCE (083)


GRADE: XII MAX MARKS: 70
DATE: 19-10-2023 DURATION: 3 HRS
General Instructions:
 Please check this question paper contains 35 questions.
 The paper is divided into 4 Sections- A, B, C, D and E.
 Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
 Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
 Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
 Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
 Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
 All programming questions are to be answered using Python Language only.

Section – A
1. State True or False
“Tuple is datatype in Python which contain data in key-value pair.”

2. Which of the following is not a keyword?


(A) eval (B) assert (C) nonlocal (D) pass

3. Given the following dictionaries


dict_student = {"rno" : "53", "name" : ‘Rajveer Singh’}
dict_marks = {"Accts" : 87, "English" : 65}
Which statement will merge the contents of both dictionaries?
(A) dict_student + dict_marks (B) dict_student.add(dict_marks)
(C) dict_student.merge(dict_marks) (D) dict_student.update(dict_marks)

4. Select the correct output of the code:


>>> s='mail2kv@kvsangathan.kvs.in'
>>> s=s.split('kv')
>>> op = s[0] + "@kv" + s[2]
>>> print(op)
(A) mail2@kvsangathan (B) mail2@sangathan.
(C) mail2@kvsangathan. (D) mail2kvsangathan.

5. Which functions is used to close a file in python?


(A) close (B) cloose() (C) Close() (D) close()
6. ________ command is used to change table structure in SQL.
(A) update (B) change (C) alter (D) modify

7. Which of the following commands will remove the entire database from MYSQL?
(A) DELETE DATABASE (B) DROP DATABASE
(C) REMOVE DATABASE (D) ALTER DATABASE

8. _____ is a non-key attribute, whose values are derived from the primary key of
some other table.
(A) Primary Key (B) Candidate Key (C) Foreign Key ( D) Alternate Key

9. The correct syntax of seek() is:


(A) seek(offset [, reference_point]) (B) seek(offset, file_object)
(C) seek.file_object(offset) (D) file_object.seek(offset [, reference_point])

10. Which of the file opening mode will open the file for reading and writing
in binary mode.
a) rb b) rb+ c) wb d) a+

11. Which of the following statements is True?


a) There can be only one Foreign Key in a table.
b) There can be only one Unique key is a table
c) There can be only one Primary Key in a Table
d) A table must have a Primary Key.

12. _______________ Keyword is used to obtain unique values in a SELECT query.


a) UNIQUE b) DISTINCT c) SET d) HAVING

13. Which statement in MySql will display all the tables in a database?
a) SELECT * FROM TABLES; b) USE TABLES;
c) DESCRIBE TABLES; d) SHOW TABLES;

14. What will be the output of the following python expression? print(2**3**2)
a) 64 b) 256 c) 512 d) 32

15. Which function is used to display the total number of records from a table in
A database?
(A) total() (B) total(*) (C) return(*) (D) count(*)

16. What will be the output of the following python dictionary operation?
data = {'A':2000, 'B':2500, 'C':3000, 'A':4000}
print(data)
a) {'A':2000, 'B':2500, 'C':3000, 'A':4000} b) {'A':2000, 'B':2500, 'C':3000}
c) {'A':4000, 'B':2500, 'C':3000} d) It will generate an error.
Q17 and 18 are ASSERTION AND REASONING based questions.
(A) Both A and R are true and R is the correct explanation for A
(B) Both A and R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) A is false but R is True

17. str1= “Class” + ”Work”


ASSERTION: Value of str1 will be “ClassWork”.
REASONING: Operator ‘+’ adds the operands, if both are numbers & concatenates
the string if both operands are strings.

18. Assertion: CSV (Comma Separated Values) is a file format for data storage which
looks like a text file.
Reason (R): The information is organized with one record on each line and each
field is separated by semi-colon.

Section – B
19. Vivek has written a code to input a number and check whether it is even or odd number.
His code is having errors. Rewrite the correct code and underline the corrections made.
Def checkNumber(N):
status = N%2
return
#main-code
num=int( input(“ Enter a number to check :))
k=checkNumber(num)
if k = 0:
print(“This is EVEN number”)
else:
print(“This is ODD number”)

20. Write two points of difference between Bus topology and star topology.
OR
Write two points of difference between XML and HTML.

21. (A) Given is a Python string declaration:


message='FirstPreBoardExam@2022-23'
Write the output of: print(message[ : : -3].upper())
(B) Write the output of the code given below:
d1={'rno':25, 'name':'dipanshu'}
d2={'name':'himanshu', 'age':30,'dept':'mechanical'}
d2.update(d1)
print(d2.keys())
22. Explain the use of ‘Foreign Key’ in a Relational Database Management System.
Give example to support your answer.

23. (A) Write the full forms of the following:


(i) HTTP (ii) FTP
(B) What is the use of TELNET?

24. Predict the output of the Python code given below:


data=["L",20,"M",40,"N",60]
times=0
alpha=""
add=0
for c in range(1,6,2):
times = times + c
alpha = alpha + data [c-1] + "@"
add = add + data[c]
print (times, add, alpha)

OR
Predict the output of the Python code given below:
L=[1,2,3,4,5]
Lst=[]
for i in range(len(L)):
if i%2==1:
t=(L[i],L[i]**2)
Lst.append(t)
print(Lst)

25. Differentiate between order by and group by clause in SQL with appropriate example.
OR
Categorize the following commands as DDL or DML:
INSERT, UPDATE, ALTER, DROP
Section – C
26. Write the output of the queries (i) to (vi) based on the table given below:

TABLE: CHIPS

BRAND_NAME FLAVOUR PRICE QUNATITY


LAYS ONION 10 5
LAYS TOMATO 20 12
UNCLE CHIPS SPICY 12 10
UNCLE CHIPS PUDINA 10 12
HALDIRAM SALTY 10 20
HALDIRAM TOMATO 25 30
(i) Select BRAND_NAME, FLAVOUR from CHIPS where PRICE <> 10;
(ii) Select * from CHIPS where FLAVOUR=”TOMATO” and PRICE > 20;
(iii) Select BRAND_NAME from CHIPS where price > 15 and QUANTITY < 15;
(iv) Select count( distinct (BRAND_NAME)) from CHIPS;
(v) Select price , price *1.5 from CHIPS where FLAVOUR = “PUDINA”;
(vi) Select distinct (BRAND_NAME) from CHIPS order by BRAND_NAME desc;

27. Write a function countINDIA() which read a text file ‘myfile.txt’ and print the frequency
of the words ‘India’ in it (ignoring case of the word).
Example: If the file content is as follows:
INDIA is my country. I live in India. India has many states.
The countIndia() function should display the output as:
Frequency of India is 3
OR

Write a function countVowel() in Python, which should read each character of a text
File “myfile.txt” and then count and display the count of occurrence of vowels (including
small cases and upper case).
Example:
If the file content is as follows:

INDIA is my country. I live in India. India has many states.

The countVowel() function should display the output as:


Total number of vowels are: 20

28. (A) Consider the following tables BOOKS and ISSUED in a database named “LIBRARY”.
Write SQL commands for the statements (i) to (iv).

Table: BOOKS

BID BNAME AUNAME PRICE TYPE QTY


COMP11 LET US C YASHWANT 350 COMPUTER 15
GEOG33 INDIA MAP RANJEET P 150 GEOGRAPHY 20
HIST66 HISTORY R BALA 210 HISTORY 25
COMP12 MY FIRST C VINOD DUA 330 COMPUTER 18
LITR88 MY DREAMS ARVIND AD 470 NOBEL 24

Table: ISSUED
BID QTY_ISSUED
HIST66 10
COMP11 5
LITR88 15
(i) Display book name and author name and price of computer type books.
(ii) To increase the price of all history books by Rs 50.
(iii) Show the details of all books in ascending order of their prices.
(iv) To display book id, book name and quantity issued for all books which have been issued.

(B) Write the command to view all tables in a database.

29. Write a function lenFOURword(L), where L is the list of elements (list of words)
passed as argument to the function. The function returns another list named ‘indexList’
that stores the indices of all four lettered word of L.
For example:
If L contains [“DINESH”, “RAMESH”, “AMAN”, “SURESH”, “KARN”]
The indexList will have [2, 4]
30. A list contains following record of a student:
[StudentName, Class, Section, MobileNumber]
Write the following user defined functions to perform given operations on the stack
named ‘xiia’:
(i) pushElement() - To Push an object containing name and mobile number of students
who belong to class xii and section ‘a’ to the stack
(ii) popElement() - 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 students details are:
[“Rajveer”, “99999999999”,”XI”, “B”]
[“Swatantra”, “8888888888”,”XII”, “A”]
[“Sajal”,”77777777777”,”VIII”,”A”]
[“Yash”, “1010101010”,”XII”,”A”]

The stack “xiia” should contain


[“Swatantra”, “8888888888”]
[“Yash”, “1010101010”]

The output should be:


[“Yash”, “1010101010”]
[“Swatantra”, “8888888888”]
Stack Empty
OR
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 25.
Also display the count of elements pushed into the stack. For example:
If the dictionary contains the following data:
Ditem = {“Rubber”:5, "Pencil":5, "Pen":30, "Notebook": 60, "Eraser":5, “Watch”: 250}
The stack should contain
Pen
Notebook
Watch
The output should be:
The count of elements in the stack is 3
Section – D
31. Layna creates a table STOCK to maintain computer stock in vidyalaya.
After creation of the table, she has entered data of 8 items in the table.

Based on the data given above answer the following questions:


(i) Identify the most appropriate column, which can be considered as Primary key.
(ii) If three columns are added and 5 rows are deleted from the table stock, what will be the
new degree and cardinality of the above table?
(iii) Write the statements to:
(a) Insert the following record into the table
Stockid - 201, dateofpurchase – 18-OCT-2022, name – neckphone Make – BoAT,
price – 500
(b) Decrease the price of stock by 5% whose were purchased in year 2020 OR
(Option for part iii only)
(iii) Write the statements to:
(a) Delete the record of stock which were purchased before year 2015.
(b) Add a column STATUS in the table with datatype as char with 1 characters
32. Sudheer has written a program to read and write using a csv file.
He has written the following code but failed to write completely, leaving some blanks.
Help him to complete the program by writing the missing lines by following the questions
________________ #Statement 1
headings = ['Country','Capital','Population']
data = [['India', 'Delhi',130],['USA','Washington DC',50],[Japan,Tokyo,2]]
f = open('country.csv','w', newline="") csvwriter = csv.writer(f)
csvwriter.writerow(headings) ________________ #Statement 2
f.close()
f = open('country.csv','r')
csvreader = csv.reader(f)
head = _________________ #Statement 3
print(head)
for x in __________: #Statement 4
if int(x[2])>50:
print(x)
a) Statement 1 – Write the python statement that will allow Sudheer
work with csv files.
b) Statement 2 – Write a python statement that will write the list
containing the data available as a nested list in the csv file
c) Statement 3 – Write a python statement to read the header row in to
the head object.
d) Statement 4 – Write the object that contains the data that has been
read from the file.
Section – E

33. A binary file data.dat needs to be created with following data written it in the
form of Dictionaries.

Rollno Name Age


1001 TOM 17
1002 BOB 16
1003 KAY 16
Write the following functions in python accommodate the data and
manipulate it.
a) A function insert() that creates the data.dat file in your system and
writes the three dictionaries.
b) A function() read() that reads the data from the binary file and displays
the dictionaries whose age is 16.

34. a) Write the output of the following code:


def change(m, n=10):
global x
x+=m
n+=x
m=n+x

print(m,n,x)
x=20
change(10)
change(20)

OR (only in a part)
What will be the output of the following python program?
str = ""
name = "9@Days"
for x in name:
if x in "aeiou":
str+=x.upper()
elif not x.isalnum():
str+="**"
elif x.isdigit():
pass
else:
str+=x.lower()
print(str)

35. What is the advantage of using a csv file for permanent storage?
Write a Program in Python that defines and calls the following user defined functions:
(i) ADD() – To accept and add data of a teacher to a CSV file ‘teacher.csv’.
Each record consists of a list with field elements as tid, name and mobile to store
teacher id, teacher name and teacher mobile number respectively.
ii) COUNTRECORD() – To count the number of records present in the CSV
file named ‘teacher.csv’.
OR
Give any one point of difference between a binary file and a csv file.
Write a Program in Python that defines and calls the following user defined functions:
(i) add() – To accept and add data of an employee to a CSV file ‘employee.csv’.
Each record consists of a list with field elements as eid, name and salary to store
employee id, employee name and employee salary respectively.
(ii) search()- To display the records of the employee whose salary is more than 40000.

You might also like