Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore CLASS 12 - CS (083) QP BOARD PATTERN

CLASS 12 - CS (083) QP BOARD PATTERN

Published by Rosna Lepcha, 2023-01-09 17:59:24

Description: CLASS 12 - CS (083) QP BOARD PATTERN

Search

Read the Text Version

Pre-Board Exam Both the case study-based questions are compulsory. Attempt any 4 sub-parts from each question. Each question carries 1 mark: (4 X 2=8) 22. Anmol maintains that database of Medicines for his pharmacy using SQL to store the data. The structure of the table PHARMA for the purpose is as follows: Name of the table - PHARMA The attributes of PHARMA are as follows: MID - numeric MNAME - character of size 20 PRICE - numeric UNITS - numeric EXPIRY – date Table: PHARMA MID MNAME PRICE UNITS EXPIRY M1 PARACETAMOL 12 120 2022-12-25 M2 CETRIZINE 6 125 2022-10-12 M3 METFORMIN 14 150 2022-05-23 M4 VITAMIN B-6 12 120 2022-07-01 M5 VITAMIN D3 25 150 2022-06-30 M6 TELMISARTAN 22 115 2022-02-25 (a) Write the degree and cardinality of the table PHARMA. cardinality-6 degree-5 (b) Identify the attribute best suitable to be declared as a primary key. MID (c) Anmol has received a new medicine to be added into his stock, but for which he does not know the number of UNITS. So he decides to add the medicine without its value for UNITS. The rest of the values are as follows: 1

MID MNAME PRICE EXPIRY M7 SUCRALFATE 17 2022-03-20 Write the SQL command which Anmol should execute to perform the required task. INSERT INTO stock (MID, MNAME, PRICE, EXPIRY) VALUES ('M7', 'SUCRALFATE', 17, '2022-03-20'); (d) Anmol wants to change the name of the attribute UNITS to QUANTITY in the table PHARMA. Which of the following commands will he use for the purpose? (i) UPDATE (ii) DROP TABLE (iii) CREATE TABLE (iv) ALTER TABLE (e) Now Anmol wants to increase the PRICE of all medicines by 5. Which of the following commands will he use for the purpose? (i) UPDATE SET (ii) INCREASE BY (iii) ALTER TABLE (iv) INSERT INTO 23. Roshni of Class 12 is writing a program in Python for her project work to create a CSV file “Teachers.csv” which will contain information for every teacher’s Identification Number, Name for some entries. She has written the following code. However, she is unable to figure out the correct statements in a few lines of the code, hence she has left them blank. Help her to write the statements correctly for the missing parts in the code 2

(a). Name the module she will import in Line 1. csv (b). In which mode will she open the file to add data into the file in Line 2? write(‘w’) mode (c). In which mode will she open the file to read the data from the file in Line 3? ‘r’ (d). Fill in the blank in Line 4 to read the data from a CSV file. (e). Fill in the blank in Line 5 to close the file. close() PART B (10 X 2=20) Section I Answer all the questions. Two questions have internal options. 24. Evaluate the following Python expressions: (a) 2 * 3 + 4 ** 2 5 // 2 This expression is invalid, because there is an extra operator (5) between 4**2 and 5//2. 3

To fix the expression, you could remove the extra operator: 2 * 3 + 4 ** 2 // 2 This expression would evaluate to 14. (b) 6 < 12 and not (20 > 15) or (10 > 5) .Here is how the expression is evaluated: 6 < 12 is True. not (20 > 15) is False. True and False is False. False or (10 > 5) is True. Therefore, the overall value of the expression is True. 25. (a) What are cookies in a web browser? Write one advantage and one disadvantage of enabling cookies in a web browser. Cookies are small pieces of data stored by a web browser that are used to store information about the user's preferences and browsing history. An advantage of enabling cookies is that they can improve the user experience by allowing websites to remember the user's preferences and settings. A disadvantage is that they may be used to track the user's online activity and serve targeted ads, which can be a privacy concern. OR 4

(b) Differentiate between the terms Domain Name and URL in context of web services. Also write one example of each to illustrate the difference. A domain name is a human-readable name that corresponds to the numerical IP address of a website, used to identify a website on the internet. Example: Domain name - \"example.com\"; A URL (Uniform Resource Locator) is a string of characters that specifies the location of a resource on the internet, typically consisting of a domain name and the path to a specific resource on the website. URL - \"https://www.example.com/products/widgets\". 26. Expand the following terms in context of Computer Networks: (a) PPP-point to point protocol (b) VoIP-Voice over Internet Protocol (c) GSM--Global System for Mobile communication (d) WLL-- Wireless Local Loop 27. (a) Explain the use of positional parameters in a Python function with the help of a suitable example. Positional parameters are function arguments in Python that are defined by their position in the function definition. When calling a function with positional parameters, the arguments must be passed in the same order as they are defined. They can have default values to make them optional. Example: def greet(name, age): print(f\"Hello, {name}! You are {age} years old.\"). OR (b) Explain the use of a default parameter in a Python function with the help of a suitable example. A default parameter is a function argument in Python with a default value specified in the function definition. If the argument is not provided when the function is called, the default value is used. Example: def greet(name, age=None). 28. Rewrite the following code in Python after removing all syntax error(s): 5

Underline each correction done in the code. 29. “Stack is a linear data structure which follows a particular order in which the operations are performed” (a) What is the order in which the operations are performed in a stack? (a) The order in which operations are performed in a stack is Last In First Out (LIFO). This means that the last element added to the stack is the first one to be removed. (b) Name the method/function with example in Python which is used to remove the last element from a Stack. (b) The method/function used to remove the last element from a stack in Python is pop(). example of how to use the pop() method to remove the last element from a stack in Python: stack = [1, 2, 3, 4] # Remove the last element from the stack last_element = stack.pop() print(stack) # Output: [1, 2, 3] print(last_element) # Output: 4 6

31. Write the names of any two constraints and their respective uses in SQL. ● A NOT NULL constraint is a rule that prevents null values from being entered into one or more columns within a table. CREATE TABLE students ( ID INT PRIMARY KEY, NAME VARCHAR(255) NOT NULL, AGE INT NOT NULL ); ● ● A unique constraint (also referred to as a unique key constraint) is a rule that forbids duplicate values in one or more columns within a table. CREATE TABLE students ( ID INT PRIMARY KEY, NAME VARCHAR(255) NOT NULL, AGE INT NOT NULL, EMAIL VARCHAR(255) UNIQUE); 32. Write the output for the execution of the following Python code: 33. Write the output of the SQL queries (a) and (b) based on the following two tables FLIGHT and PASSENGER belonging to the same database: 7

(a) SELECT NAME, DEPART FROM FLIGHT NATURAL JOIN PASSENGER; NAME DEPART PRAKASH DELHI NOOR MUMBAI (b) SELECT NAME, FARE FROM PASSENGER P, FLIGHT F WHERE F.FNO = P.FNO AND F.DEPART = ‘MUMBAI’; q Section II (4 X 3=12) Answer all the questions. Two questions have internal options. 8

34. Write the definition of a function Sum3 (L) in Python, which accepts a list L of integers and displays the sum of all such integers from the list L which end with the digit 3. For example, if the list L is passed [123, 10, 13, 15, 23] Then the function should display the sum of 123, 13, 23, i.e. 159 as follows: Sum of integers ending with digit 3 = 159 Sum3() functionis the function that accepts a list of integers and displays the sum of all integers ending with the digit 3: Copy code def Sum3(L): total = 0 for x in L: if x % 10 == 3: # Check if the last digit is 3 total += x print(f\"Sum of integers ending with digit 3 = {total}\") Here is an example of how to use the Sum3() function: Copy code Sum3([123, 10, 13, 15, 23]) # Output: Sum of integers ending with digit 3 = 159 This would print the following output: Copy code Sum of integers ending with digit 3 = 159 . 9

35. (a) Write the definition of a function POP_PUSH (LPop, LPush, N) in Python. The function should Pop out the last N elements of the list LPop and Push them into the list LPush. For example: If the contents of the list LPop are [10, 15, 20, 30] and value of N passed is 2, then the function should create the list LPush as [30, 20] and the list LPop should now contain [10, 15] NOTE: If the value of N is more than the number of elements present in LPop, then display the message \"Pop not possible\". Here is the definition of the POP_PUSH() function in Python that pops the last N elements from a list LPop and pushes them into another list LPush: Copy code def POP_PUSH(LPop, LPush, N): if N > len(LPop): # Check if N is more than the number of elements in LPop print(\"Pop not possible\") else: for i in range(N): # Pop the last element from LPop and append it to LPush LPush.append(LPop.pop()) Here is an example of how to use the POP_PUSH() function: LPop = [10, 15, 20, 30] LPush = [] POP_PUSH(LPop, LPush, 2) print(LPop) # Output: [10, 15] print(LPush) # Output: [30, 20] OR (b) Write a function in Python POPSTACK (L) where L is a stack implemented by a list of numbers. The function returns the value deleted from the stack. 10

Here is the definition of the POPSTACK() function in Python that accepts a stack implemented as a list of numbers and returns the value deleted from the stack: def POPSTACK(L): if len(L) > 0: # Check if the stack is not empty return L.pop() # Pop the last element from the stack and return it else: return None # Return None if the stack is empty Here is an example of how to use the POPSTACK() function: stack = [10, 20, 30] x = POPSTACK(stack) print(x) # Output: 30 print(stack) # Output: [10, 20] This would pop the last element (30) from the stack and return it as the output. The stack list would then be modified to remove the last element. 36. (a) A binary file \"PATIENTS.dat\" has structure (PID, NAME, DISEASE). Write the definition of a function countrec ()in Python that would read contents of the file \"PATIENTS.dat\" and display the details of those patients who have the DISEASE as 'COVID-19'. The function should also display the total number of such patients whose DISEASE is 'COVID-19'. 11

OR (b) A binary file \"PLANTS.dat\" has structure (ID, NAME, PRICE). Write the definition of a function WRITEREC () in Python, to input data for records from the user and write them to the file PLANTS.dat. Write the definition of a function SHOWREC () in Python, which reads the records of PLANTS.dat and displays the plants records. 37. Write SQL statements for the following queries (i) to (III) based on the relations CUSTOMER given below : 12

(A) To display all information about the CUSTOMERs whose NAME starts with 'A'. SELECT * FROM CUSTOMER WHERE NAME LIKE “A%”; (B) To display the NAME and BALANCE of Female CUSTOMERs (with GENDER as 'F') SELECT NAME, BALANCE FROM CUSTOMER WHERE GENDER=”F”; (C) To display the CUSTOMER NAME and BALANCE in ascending order of GENDER. SELECT NAME, BALANCE FROM CUSTOMER ORDER BY GENDER ASC; SECTION III Answer all the long answer questions of 5 marks each: (3 X 5=15) 38. Consider the following code and answer the questions that follow: Book={1:'Thriller', 2:'Mystery', 3:'Crime', 4:'Children Stories'} Library ={'5':'Madras Diaries','6':'Malgudi Days'} (a) Ramesh needs to change the title in the dictionary book from ‘Crime’ to ‘Crime Thriller’. He has written the following command: Book[‘Crime’]=’Crime Thriller’ But he is not getting the answer. Help him choose the correct command: (i) Book[2]=’Crime Thriller’ (ii) Book[3]=’Crime Thriller’ (iii) Book[2]=(’Crime Thriller’) (iv) Book[3] =(‘Crime Thriller’) (b) The command to merge the dictionary Book with Library the command would be: (i) d=Book+Library 13

(ii) print(Book+Library) (iii) Book.update(Library) (iv) Library.update(Book) (c) What will be the output of the following line of code: print (list(Library)) (i) [‘5’,’Madras Diaries’,’6’,’Malgudi Days’] (ii) (‘5’,’Madras Diaries’,’6’,’Malgudi Days’) (iii) [’Madras Diaries’,’Malgudi Days’] (iv) [‘5’,’6’] (d) In order to check whether the key 2 is present in the dictionary Book, Ramesh uses the following command: 2 in Book He gets the answer ‘True’. Now to check whether the name ‘Madras Diaries’ exists in the dictionary Library, he uses the following command: ‘Madras Diaries’ in Library But he gets the answer as ‘False’. Select the correct reason for this: (i) We cannot use the in function with values. It can be used with keys only. (ii) We must use the function Library.values() along with the in operator (iii) We can use the Library.items() function instead of the in operator (iv) Both b and c above are correct. (e) With reference to the above declared dictionaries, predict the output of the following code fragments: 14

(a) (b) (c) (d) 15

39. In a Database, there are two tables with the instances given below: (a) Choose the command to display name and game of those students whose address is available in students’ table. (i) SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=SPORTS.ADMNO AND ADDRESS IS NOT NULL; (ii) SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=SPORTS.ADMNO AND ADDRESS IS NULL; (iii) SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=SPORTS.ADMNO, ADDRESS IS NULL; (iv) SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=SPORTS.ADMNO NOT ADDRESS IS NULL; (b) Identify the statement to delete a column phone from the table students. (i) ALTER TABLE STUDENTS DROP PHONE; (ii) DROP PHONE; (iii) UPDATE DROP PHONE; (iv) DELETE FROM STUDENTS WHERE DROP PHONE; 16

(c) Choose the command to display Name of the students who are studying in class 12 and their corresponding Coach names (i) SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLASS LIKE “12%” AND STUDENTS.ADMNO =SPORTS.ADMNO; (ii) SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLASS LIKE “12%” AND STUDENTS.ADMNO= SPORTS.ADMNO; (iii) SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLASS LIKE “12%” AND ADMNO.STUDENTS =ADMNO.SPORTS; (iv) SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLASS LIKE= “12%” AND STUDENTS.ADMNO =SPORTS.ADMNO; (d) Which two select queries will give the same output? (i) SELECT NAME, GRADE FROM STUDENTS,SPORTS WHERE ADDRESS IS NULL AND STUDENTS.ADMNO =SPORTS.ADMNO ; (ii) SELECT NAME, GRADE FROM STUDENTS,SPORTS WHERE ADDRESS IS NOT NULL AND STUDENTS.ADMNO =SPORTS.ADMNO ; (iii) SELECT NAME, GRADE FROM STUDENTS,SPORTS WHERE ADDRESS IS NULL OR STUDENTS.ADMNO=SPORTS.ADMNO ; (iv) SELECT ST.NAME, SP.GRADE FROM STUDENTS ST,SPORTS SP WHERE ADDRESS IS NULL AND ST.ADMNO=SP.ADMNO ; A. i AND ii B. ii AND iii C. i AND iv D. iii AND iv (e) Choose the command to count the number of students who play volleyball (i) SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE GAME=”VOLLEYBALL” AND STUDENTS.ADMNO=SPORTS.ADMNO ; (ii) SELECT COUNT(GAME) FROM STUDENTS,SPORTS WHERE GAME=”VOLLEYBALL” AND STUDENTS.ADMNO=SPORTS.ADMNO ; (iii) SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE GAME=”VOLLEYBALL” ; 17

(iv) SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE SPORTS=”VOLLEYBALL” AND STUDENTS.ADMNO=SPORTS.ADMNO 40. A company ABC Enterprises has four blocks of buildings as shown: Center to center distance between various blocks: Number of computers in each block: Computers in each block are networked but blocks are not networked. The company has now decided to connect the blocks also. (A) Suggest the most appropriate topology for the connections between the blocks. (i) Ring topology (ii) Star topology (iii) Mesh topology (iv) Bus topology 18

(B) The company wants internet accessibility in all the blocks. The suitable and cost-effective technology for that would be: (i) Satellite (ii) Lease line (iii) Telephone line (iv) Broadband (C) Which one of the following devices will you suggest for connecting all the computers within each of their blocks? (i) Switch/Hub (ii) Modem (iii) Telephone (iv) Repeater (D) The company is planning to link its head office situated in New Delhi with the offices in hilly areas. Suggest a way to connect it economically: (i) Microwaves (ii) Coaxial cable (iii) Fibre optic (iv) Radio waves (E) Suggest the most appropriate location of the server, to get the best connectivity for the maximum number of computers. (i) BLOCK B2 (ii) BLOCK B1 (iii) BLOCK B4 (iv) BLOCK B3 1.Which of the following options is/are not Python Keywords ? (A) False (B) Math (C) WHILE (D) break 2. Given the dictionary D={'Rno': 1, 'Name':'Suraj'} , write the output of print(D('Name')) 19

type error because you cannot use the () operator to access the value of a key in a dictionary. 3. Identify the statement(s) from the following options which will raise TypeError exception(s) : (A) print('5' * 3) (B) print( 5 * 3) (C) print('5' + 3) (D) print('5' + '3') 4. Identify the valid relational operator(s) in Python from the following : (A) = (B) < (C) <> (D) not 5. For a string S declared as S = 'PYTHON', which of the following is incorrect ? (A) N=len(S) (B) T = S (C) 'T' in S (D) S[0] = 'M' 6. Write a single line statement in Python to assign the values 'BLUE', 'GREEN', 'RED' to a tuple named Colours. Colours = ('BLUE', 'GREEN', 'RED') 7. A List is declared as L = ['ONE', 'TWO', 'THREE'] What will be the output of the statement ? print(max(L)) —-Two 8. Write the name of the built-in function/method of the math module which when executed upon 5.8 as parameter, would return the nearest smaller integer 5. 20

floor(). 9. In context of Communication Networks, which of the following is the correct expansion for the abbreviation PAN : (A) Prime Area Network (B) Post Application Network (C) Picture Application Network (D) Personal Area Network 10. In context of Cyber Crimes and Cyber Thefts, the term IPR refers to : (A) Internet Protocol Rights (B) Inter Personnel Rights (C) Intellectual Property Rights (D) Individual Property Rights 11. In SQL, write the name of the aggregate function which will display the cardinality of a table. COUNT(). 12. Which of the following clauses in SQL is most appropriate to use to select matching tuples in a specific range of values ? (A) IN (B) LIKE (C) BETWEEN (D) IS 13. Which of the following is not a valid datatype in SQL ? (A) DATE (B) STRING (C) DECIMAL (D) CHAR 21

14. Which of the following is not a valid DML command in SQL ? (A) INSERT (B) UPDATE (C) ALTER (D) DELETE 15. Which of the following wireless transmission media is best suited for MAN ? (A) Microwave (B) Radio Link (C) Infrared (D) Bluetooth 16. Which of the following is/are immutable object type(s) in Python ? (A) List (B) String (C) Tuple (D) Dictionary 17. What shall be the ouput for the execution of the following Python Code ? Cities = ['Delhi', 'Mumbai'] Cities[0], Cities[1] = Cities[1], Cities[0] print(Cities) ['Mumbai', 'Delhi'] 18. Which of the following commands in SQL is used to add a new record into a table ? (A) ADD (B) INSERT (C) UPDATE (D) NEW 22

19. Which of the following is the correct expansion of DML in context of SQL ? (A) Direct Machine Language (B) Data Mixing Language (C) Distributed Machine Language (D) Data Manipulation Language 20. Which of the following statements correctly explains the term Firewall in context of Computer Network Society ? (A) A device that protects the computer network from catching fire. (B) A device/software that controls incoming and outgoing network traffic. (C) Using abusive language on a social network site . (D) Stea it as his/her own work. 21. Which of the following protocols allows the use of HTML on the World Wide Web ? (A) HTTP-hypertext transfer protocol (B) PPP (C) FTP–file transfer protocol (D) POP –post office protocol 23


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook