Content text Computer Science Solved Papers.pdf
4 CBSE Computer Science 2025 OR (b) Write a statement to display the length of the dictionary D1. (ii) (a) Write a statement to append all the key-value pairs of the dictionary D to the dictionary D1. OR (b) Write a statement to delete the item with the given key “Amit” from the dictionary D1. Ans. (i) (a) D.get(“Raj”) OR (b) len(D1) (ii) (a) D1.update(D) OR (b) D1.pop(“Amit”) Explanation: The get() method returns the value for the key specified in a dictionary. The len() method returns the number of items in a dictionary. The update() method updates the values of a dictionary by another. The pop() method removes a key:value pair from dictionary. 25. What possible output from the given options is expected to be displayed when the following code is executed? [2] import random Cards=[“Heart”,”Spade”,”Club”,”Diamond”] for i in range(2): print(Cards[random.randint(1,i+2)],end=”#”) (A) Spade#Diamond# (B) Spade#Heart# (C) Diamond#Club# (D) Heart#Spade# Ans. (A) Spade#Diamond# Explanation: The range function returns the values 0,1 , hence the values of i will be 0 and 1 in the two iterations. Therefore the parameters to the randint() function will be 1,2 and 1,3 thereby giving the values “Spade” in the 1st iteration and “Club” or “Diamond” in the 2nd iteration . Therefore the possible option is A. 26. The code given below accepts N as an integer argument and returns the sum of all integers from 1 to N. Observe the following code carefully and rewrite it after removing all syntax and logical errors. Underline all the corrections made. [2] def Sum (N) for I in range (N) : S = S + I return S print (Sum (10) Ans. def Sum(N): Missing Colon for I in range(1,(N+1)): Incorrect loop – Should be from1 to N+1 S = S + I return S print(Sum(10)) Braces missing. 27. Nisha is assigned the task of maintaining the staff data of an organization. She has to store the details of the staff in the SQL table named EMPLOYEES with attributes as EMPNO, NAME, DEPARTMENT, BASICSAL to store Employee’s Identification Number, Name, Department, and Basic Salary respectively. There can be two or more Employees with the same name in the organization. [2] (i) (a) Help Nisha to identify the attribute which should be designated as the PRIMARY KEY. Justify your answer. OR (b) Help Nisha to identify the constraint which should be applied to the attribute NAME such that the Employees’ Names cannot be left empty or NULL while entering the records but can have duplicate values. (ii) (a) Write the SQL command to change the size of the attribute BASICSAL in the table EMPLOYEES to allow the maximum value of 99999.99 to be stored in it. OR (b) Write the SQL command to delete the table EMPLOYEES. Ans. (i) (a) EMPNO: As name of employee can be duplicate . OR (b) NOT NULL: Restricts input of NULL values but allows duplicate values. (ii) (a) Alter table Employees Modify Basicsal double(8, 2); OR (b) Drop table Employees. 28. (a) Expand and explain the term URL. [2] OR (b) Expand the term PPP. What is the use of PPP?