CBSE SAMPLE PAPER 1 COMPUTER SCIENCE
Class XII
Computer Science (083)
Sample Paper I
General Instructions :
(i) Please check this question paper, which contains 35 questions.
(ii) The paper is divided into 5 Sections - A, B, C, D and E.
(iii)Section A, consists of 18 questions (1 to 18). Each question carries 1 mark.
(iv)Section B consists of 7 questions (19 to 25). Each question carries 2 marks.
(v)Section C consists of 5 questions (26 to 30). Each question carries 3 marks.
(vi)Section D consists of 2 questions (31 to 32). Each question Carries 4 marks.
(vii) Section E, consists of 3 questions (33 to 35). Each question carries 5 marks.
(viii) All programming questions will be answered using Python Language only.
SECTION - A
"Python is an interpreted language."
2. Which of the following are keywords in Python?
a) break
b) check
c) range
d) while
3. Which of the following is not a sequential datatype in Python?
(a) Dictionary
(b) String
(c) List
(d) Tuple
4. In Python, what does the len( ) function primarily measure for a string?
A. Number of characters
B. Memory usage
C. Byte size
D. String length
5. Fill in the blank :
_________ statement of SQL is used to insert new records in a table.
(a) ALTER
(b) UPDATE
(c) INSERT
(d) CREATE
6. Write the names of the immutable data objects from the following :
(a) List
(b) Tuple
(c) String
(d) Dictionary
7. Which of the following is NOT a Python exception?
(a) ValueError
(b) IOError
(c) ModuleError
(d) IndexError
8. The correct syntax of the tell( ) methods is :
(a) tell.file_object( )
(b) file_object.tell( )
(c) tell.file_object(1 )
(d) file_object.tell(1)
9. Which statement(s) would give an error after executing the following code?
S="Happy" # Statement 1
print(S*2) # Statement 2
S+="Independence" # Statement 3
S.append("Day") # Statement 4
print(S). # Statement 5
(a) Statement 2
(b) Statement 3
(c) Statement 4
(d) Statements 3 and 4
10. How can we retrieve all the columns from the' Student' table?
(a) SELECT * FROM Student
(b) RETRIEVE ALL FROM Student
(c) SELECT ALL FROM Student
(d) GET * FROM Student
11. Which of the following is an invalid variable name in Python?
(a) _name
(b) name1
(c) 1name
(d) name_
12. Which symbol is used in Python to make a single-line comment?
(a) //
(b) #
(c) *
(d) /* */
13. In packet switching, data is broken down into smaller units called _________.
(a) Packets
(b) Segments
(c) Fragments
(d) Blocks
14. Which of the following is NOT a Python data type?
(a) tuple
(b) listicle
(c) dict
(d) set
15. What does the term 'relation' refer to in a relational database?
(a) Function
(b) Table
(c) Database
(d) Relation between tables
16. Which of the following is the correct file mode to append to a file in Python?
(a) 'r'
(b) 'a'
(c) 'x'
(d) 'w'
Q. 17 and 18 are ASSERTION (A) AND REASONING (R) based questions. Mark the correct choice as:
(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.
Assertion (A): In Python, lists are mutable.
Reason (R): Mutable means the content of the variable can be changed after declaring it.
18.
Assertion (A): In SQL, the 'JOIN' command combines rows from two or more tables.
Reason (R): It's based on a related column between them.
SECTION B
19. Write any two differences between Fiber-optic cable and Coaxial cable.
OR
(b) Write one advantage and one disadvantage of wired over wireless Communication.
20. (a)Given is a Python string declaration:
NAME = "Learning Python is Fun"
Write the output of : print(NAME[-5:-10:-1])
(b) If x = (10, 20, (30, 40), [50, 60])
what will be the result of x[3][0]?
21. Consider the Python code :
data = {
" Mike " : [88, 92, 79],
" Lucy " : [91, 87, 90] ,
" John " : [85, 86, 88]
}
This dictionary represents the marks of three students in three subjects. Write a Python function to calculate the average marks of each student.
22. Explain the concept of Unique Key in Relational Database Management Systems. Also, provide an example illustrating its use.
23. (A) Write the full form of :
i)PPP
ii)TCP/ IP
(B) What do you understand by domain names? Why these are necessary?
24. Consider the table Sales given below:
Order_ID | Product | Quantity | Price | Date |
1 | Laptop | 5 | 50000 | 2024-01-15 |
2 | Mouse | 50 | 500 | 2024-02-18 |
3 | Keyboard | 30 | 1500 | 2024-03-10 |
4 | Monitor | 10 | 10000 | 2024-04-05 |
5 | Laptop | 3 | 55000 | 2024-05-25 |
Based on the table, write SQL queries for the following:
(i) Calculate the total quantity of all products sold.
(ii) Find the average price of products sold.
(iii) Determine the maximum price for all products.
25. (A) Ravi, a Python programmer, is working on a project where he wants to write a function to count the number of even and odd values in the list. He has written the following code but his code is having errors. Rewrite the correct code and underline the corrections made.
define EOCOUNT(L):
even_no=odd_no=0
for i in range(0,len(L))
if L[i]%2=0:
even_no+=1
Else:
odd_no+=1
print(even_no, odd_no)
SECTION C
26. Write the outputs of the SQL queries (i) to (iii) based on the relations CUSTOMER and TRANSACTION given below :
Table- CUSTOMER
ACNO | NAME | GENDER | BALANCE |
C1 | RISHABH | M | 15000 |
C2 | AAKASH | M | 12500 |
C3 | INDIRA | F | 9750 |
C4 | TUSHAR | M | 14600 |
C5 | ANKITA | F | 22000 |
Table - TRANSACTION
ACNO | TDATE | AMOUNT | TYPE |
C1 | 2020-07-21 | 1000 | DEBIT |
C5 | 2019-12-31 | 1500 | CREDIT |
C3 | 2020-01-01 | 2000 | CREDIT |
( i ) SELECT MAX (BALANCE), MIN (BALANCE) FROM CUSTOMER
WHERE GENDER = ' M ' ;
( ii ) SELECT SUM (AMOUNT), TYPE FROM TRANSACTION GROUP BY TYPE ;
( iii ) SELECT NAME, TDATE, AMOUNT
FROM CUSTOMER C, TRANSACTION T
WHERE C.ACNO = T .ACNO AND TYPE = 'CREDIT' ;
27. ( A ) Create a Python function named WordFrequency( ) which takes the contents from a file 'WORDS.TXT' and displays the frequency of each word.
For example, if the file contains:
apple apple banana apple cherry cherry
The function should display:
apple: 3
banana: 1
cherry: 2
OR
( B) Develop a Python function called EvenLines( ) that reads from a file 'LINES.TXT' and only displays the even-numbered lines.
For example, the file content:
This is line one.
This is line two.
This is line three.
This is line four.
The output should be:
This is line two.
This is line four.
28. Write the output of any three SQL queries (i) to (iv) based on the tables COMPANY and CUSTOMER given below :
Table: COMPANY
CID | C NAME | CITY | PRODUCT NAME |
111 | SONY | DELHI | TV |
222 | NOKIA | MUMBAI | MOBILE |
333 | ONIDA | DELHI | TV |
444 | SONY | MUMBAI | MOBILE |
555 | BLACKBERRY | CHENNAI | MOBILE |
666 | DELL | DELHI | LAPTOP |
Table: CUSTOMER
CUSTID | CID | NAME | PRICE | QTY |
C01 | 222 | ROHIT SHARMA | 70000 | 20 |
C02 | 666 | DEEPIKA KUMARI | 50000 | 10 |
С03 | 111 | MOHAN KUMAR | 30000 | 5 |
CO4 | 555 | RADHA MOHAN | 30000 | 11 |
i) SELECT PRODUCTNAME,
COUNT(*)FROM COMPANY GROUP BY
PRODUCTNAME HAVING COUNT(*)> 2;
(ii) SELECT NAME, PRICE,
PRODUCTNAME FROM COMPANY C,
CUSTOMER CT WHERE C.CID = CU.CID AND C_NAME = 'SONY';
(iii) SELECT DISTINCT CITY FROM COMPANY;
(iv) SELECT * FROM COMPANY WHERE C_NAME LIKE '%ON%';
29. Write a function HalveEven( ) in Python, which accepts a list L of numbers. After that, it halves all even numbers.
Example:
If the Sample Input data of the list is: L = [10, 12, 15, 28, 33]
Output will be: L = [5, 6, 15, 14, 33]
30. A list contains the following record of customers: (Customer_ name, Room Type]
Write the following user-defined functions to perform given operations on the stack named 'Hotel' :
(i) Push_Cust ( ) - To Push customers' names of those customers who are staying in the 'Delux' Room Type.
(ii) Pop_Cust ( ) - To Pop the names of customers from the stack and display them. Also, display "Underflow" when there are no customers in the stack.
For example :
If the lists with customer details are as follows :
["Siddarth", "Delux"] ["Rahul", "Standard"]
["Jerry", "Delux"]
The stack should contain
Jerry
Siddharth
The output should be:
Jerry
Siddharth
Underflow
SECTION D
31. A startup has hired Ms. Serena to manage their team of developers. She's required to keep a record of all the developers with their skills and experience.
DEV_ID | DEV_NAME | SKILL | EXPERIENCE (in years) | TEAM |
D001 | John | Python | 3 | Web |
D002 | Alice | | JavaScript | 5 | Frontend |
D003 | Bob | SQL | 2 | Backend |
D004 | Carol | Java | 4 | Mobile |
Based on the data given above, answer the following questions:
(i) Identify the columns that can be considered as Candidate keys.
(ii) Write the SQL commands to:
(a) Add a new developer with relevant details.
(b) Update the experience of a developer by 1 year.
(iii) Write the SQL statements to:
(a) Add a constraint PRIMARY KEY to the column DEV_ID.
(b) Remove the record of a developer by DEV_ID.
32. Atharva is a programmer, who has recently been given a task to write a Python code to perform the following binary file operation with the help of a user-defined function/module :
Copy_new(): to create a binary file new_items.dat and write all the item details stored in the binary file, items.dat, except for the item whose item_id is 101. The data is stored in the following format: { item_id: [item_name, amount]}
import ___________ # Statement 1
def Copy_new():
f1=_____________ # Statement 2
f2=_____________ # Statement 3
item_id=int(input("Enter the item id"))
item_detail=___________ # Statement 4
for key in item_detail:
if _______________: # Statement 5
pickle.___________ # Statement 6
f1.close()
f2.close()
He has succeeded in writing partial code and has missed out certain statements. Therefore, as a Python expert, help him to complete the code based on the given requirements :
(i) Which module should be imported into the program? (Statement 1)
(ii) Write the correct statement required to open the binary file "items.dat". (Statement 2)
(iii) a) Which statement should Atharva fill in Statement 3 to open the binary file "new_items.dat" and in Statement 4 to read all the details from the binary file "items.dat"?
OR (Option for part iii only)
(iii)b) What should Atharva write in Statement 5 to apply the given condition and in Statement 6 to write data in the binary file "new_items.dat"?
SECTION E
33. XYZ Techcorp is establishing a new campus in Bengaluru with its head office in Mumbai. The Bengaluru campus has five buildings:
Bengaluru Campus Layout
Block to Block distances (in Mtrs.)
From | To | Distance |
ADMIN | HR | 30 m |
ADMIN | DEVELOPMENT | 80 m |
ADMIN | SALES | 60 m |
HR | DEVELOPMENT | 50 m |
HR | SALES | 40 m |
DEVELOPMENT | SALES | 70 m |
DEVELOPMENT | IT | 90 m |
SALES | IT | 50 m |
The number of computers in each of the blocks/Centers is as follows:
Block | Computers |
ADMIN | 150 |
HR | 70 |
DEVELOPMENT | 100 |
SALES | 40 |
IT | 80 |
MUMBAI HEAD OFFICE | 30 |
Based on the above-given information, answer the following questions.
(a) Suggest and draw the cable layout to efficiently connect various blocks of buildings within the BENGALURU campus for connecting digital devices.
(b) Which network device will be used to connect computers in each block to form a local area network?
(c) Which block in the Bengaluru Campus should be made the server? Justify your answer.
(d) Which fast and very effective wireless transmission medium should preferably be used to connect the head office in MUMBAI with the campus in BENGALURU?
(e) Is there a requirement for a repeater in the given cable layout? Why/Why not?
34. (A ) Write a point of difference between append (a) and write (w) modes in a text file.
(B). Write a program in Python that defines and calls the following user-defined functions :
(i) Add_Teacher( ): It accepts the values from the user and the Inserts record consists of a list with field elements as T_id, Tname and design to store teacher ID, teacher name and designation respectively.
(ii) Search_Teacher( ): To display the records of all the PGT(designation) teachers.
OR
(A ) Write one point of difference between the seek( ) and tell( ) functions in file handling.
(B) Write a program in Python that defines and calls the following user-defined functions :
(i) Add_Device(): The function accepts and adds records of the consists of a list with field elements as P_id, P_name and Price to store peripheral device ID, device name, and price respectively.
(ii) Count_Device(): To count and display the number of peripheral devices, whose price is less than < 1000.
35. (A) Predict the output of the following code:
x = "HELLO"
for char in x:
if char == 'E':
continue
print(char, end='')
(a) HELLO
(b) HLL
(c) HLLO
(d) HLO
(B) The provided code updates the products table to set the price of the item with P_code P504 to 150.
- Username is store admin
- Password is store_pass
- The database is named "store_db"
- The attributes of the table are (P_code, P_name, P_price, P_category)
import ________ as db_module # Statement 1
def update_price():
db_connection = db_module.connect(host="localhost", user="storeadmin", passwd="________", database="store_db") # Statement 2
cursor = db_connection.cursor()
_______________ # Statement 3 (Update the price of the product with P_code 'P504')
_______________ # Statement 4 (Commit the changes)
print("Price updated")
Complete the above statement by filling in the blanks.