{"id":156293,"date":"2024-01-02T12:20:31","date_gmt":"2024-01-02T06:50:31","guid":{"rendered":"https:\/\/www.learncbse.in\/?p=156293"},"modified":"2024-01-02T14:42:56","modified_gmt":"2024-01-02T09:12:56","slug":"cbse-sample-papers-for-class-12-computer-science-set-4","status":"publish","type":"post","link":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/","title":{"rendered":"CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions"},"content":{"rendered":"

Students must start practicing the questions from\u00a0CBSE Sample Papers for Class 12 Computer Science with Solutions<\/a> Set 4 are designed as per the revised syllabus.<\/p>\n

CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions<\/h2>\n

Time: 3 hrs Max.
\nMarks: 70<\/p>\n

Instructions<\/span><\/p>\n

1. Please check this question paper contains 35 questions.
\n2. The paper is divided into 5 Sections A, B, C, D and E.
\n3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
\n4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
\n5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
\n6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
\n7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
\n8. All programming questions are to be answered using Python Language only.<\/p>\n

Section – A<\/span><\/p>\n

Question 1.
\nState True or False [1]
\n“Lists and dictionaries are mutable.”
\nAnswer:
\nTrue<\/p>\n

Question 2.
\nIn complex number a + ib, b represents as [1]
\n(a) real part
\n(b) imaginary part
\n(c) special part
\n(d) None of these
\nAnswer:
\n(b) imaginary part<\/p>\n

\"CBSE<\/p>\n

Question 3.
\nGiven an object obj1 = (10, 20, 30, 40, 50, 60, 70, 80, 90). What will be the output of print(obj1[3 : 7 : 2])? [1]
\n(a) (40, 50, 60, 70, 80)
\n(b) (40, 50, 60, 70)
\n(c) (40, 50, 60)
\n(d) (40, 60)
\nAnswer:
\n(d) (40,60)<\/p>\n

Question 4.
\nWhich of the following is the correct output for the execution of the following Python statement? [1]<\/p>\n

print (5 + 3 ** 2\/2)<\/pre>\n

(a) 32
\n(b) 8.0
\n(c) 9.5
\n(d) 32.0
\nAnswer:
\n(c) 9.5<\/p>\n

Question 5.
\nIdentify the output from the following options. [1]<\/p>\n

sub = \"PYTHON\"\r\nfor i in sub\r\nprint (i, ' ', end = \" \")<\/pre>\n

(a) P Y T H O N
\n(b) P
\nY
\nT
\nH
\nO
\nN
\n(c) None
\n(d) P,Y,T,H,O,N
\nAnswer:
\n(a) P Y T H O N<\/p>\n

Question 6.
\nWhich path does not start with a leading forward slash ? [1]
\n(a) Relative
\n(b) Absolute
\n(c) Both (a) and (b)
\n(d) None of these
\nAnswer:
\n(a) Relative<\/p>\n

Question 7.
\nIP address are converted into [1]
\n(a) a binary string
\n(b) alphanumeric string
\n(c) a hierarchy of domain name
\n(d) a hexadecimal
\nAnswer:
\n(c) a hierarchy of domain name<\/p>\n

Question 8.
\nWhich of the following SQL commands displays the structure of a table? [1]
\n(a) ALTER
\n(b) STRUCTURE
\n(c) DESCRIBE
\n(d) SHOW DATA
\nAnswer:
\n(c) DESCRIBE<\/p>\n

\"CBSE<\/p>\n

Question 9.
\nObserve the following tuples and choose the correct option [1]<\/p>\n

t1=(4, 7, 8, 9)\r\nt2=(0, 4, 3)\r\n>>>t=t1+t2\r\n>>>print(t)<\/pre>\n

(a) (4, 7, 8, 9, 0, 4, 3)
\n(b) (4, 7, 8, 9, 4, 7, 8, 9)
\n(c) (4, 7, 8, 9)
\n(d) None of these
\nAnswer:
\n(a) (4, 7, 8, 9, 0, 4, 3)<\/p>\n

Question 10.
\nAssume that the position of the file pointer is at the beginning of 3rd line in a text file. Which of the following option can be used to read all the remaining lines? [1]
\n(a) myfile.read(n-3)
\n(b) myfile.read(n)
\n(c) myfile.readline()
\n(d) myfile.readlines()
\nAnswer:
\n(d) myfile.readlines()<\/p>\n

Question 11.
\nFill in the blank : ……… is an attribute that makes a link between two tables to fetch corresponding data. [1]
\n(a) Primary key
\n(b) Secondary key
\n(c) Foreign key
\n(d) Composite key
\nAnswer:
\n(c) Foreign key<\/p>\n

Question 12.
\nWhich of the following function returns the total number of values? [1]
\n(a) MAX
\n(b) MIN
\n(c) COUNT
\n(d) SUM
\nAnswer:
\n(c) COUNT<\/p>\n

Question 13.
\nState whether the following statement is True or False. The clause to get the unique values from a field of a table is DISTINCT. [1]
\nAnswer:
\nTrue<\/p>\n

Question 14.
\nWhich of the following is the correct output for the following execution ? [1]
\nprint(print(“Biscope”))
\n(a) Biscope
\n(b) None
\n(c) Biscope
\nNone
\n(d) Error
\nAnswer:<\/p>\n

Question 15.
\nFill in the blank : …….. is a protocol used for uploading and downloading of files in a network. [1]
\nAnswer:
\nFTP<\/p>\n

Question 16.
\nWhat is default value of host? [1]
\n(a) host
\n(b) localhost
\n(c) globalhost
\n(d) None of these
\nAnswer:
\n(b) localhost<\/p>\n

Directions In the question numbers 17 and 18, a statement of Assertion (A) is followed by a statement of Reason (R). Choose the correct option.<\/p>\n

Question 17.
\nAssertion (A) Built-in functions are predefined in the system and can be directly used in any program. [1]
\nReason (R) id() and type() are built-in functions in Python.
\n(a) Both A and R are true and R is the correct explanation for A.
\n(b) Both A and R are true but R is not the correct explanation for A.
\n(c) A is true but R is false.
\n(d) A is false but R is true.
\nAnswer:
\n(b) Both A and R are true but R is not the correct explanation for A.<\/p>\n

Question 18.
\nAssertion (A) The CSV files are like TEXT files and are comma separated value files. [1]
\nReason (R) The data stored in CSV files are separated by comma by default. Although the delimiter can be changed.
\n(a) Both A and R are true and R is the correct explanation for A.
\n(b) Both A and R are true but R is not the correct explanation for A.
\n(c) A is true but R is false.
\n(d) A is false but R is true.
\nAnswer:
\n(a) Both A and R are true and R is the correct explanation for A.<\/p>\n

Section – B<\/span><\/p>\n

Question 19.
\n(i) Expand the following terms: [1+1=2]
\nMAN, FTP
\n(ii) What was the role of ARPANET in the computer network? [2]<\/p>\n

Or<\/p>\n

(i) Name two switching techniques used to transfer data between two terminals (computers).
\n(ii) How can a Word document be sent alongwith an E-mail? [2]
\nAnswer:
\n(i) MAN Metropolitan Area Network FTP File Transfer Protocol
\n(ii) ARPANET (Advanced Research Projects Agency Network) goal was to connect computers at different universities and US defense. ARPANET started with a handful of computers but it expanded rapidly.<\/p>\n

Or<\/p>\n

(i) Switching techniques used to transfer data between two terminals are [2]
\n(a) Circuit switching
\n(b) Packet switching
\n(ii) By attaching the Word file with an E-mail.<\/p>\n

Question 20.
\nRiya was asked to accept a list of even numbers, but she did not put the relevant condition while accepting the list of numbers. She wrote a user-defined function oddtoeven (L) that accepts the list L as an argument and converts all the odd numbers into even by multiplying them by 2. [2]<\/p>\n

def oddtoeven (L) :\r\nfor i in range (sized(L)):\r\nif (L[i]% 2! == 0)\r\nL [i] = L [i] ** 2\r\nprint (L)<\/pre>\n

There are some errors in the code. Rewrite the correct code.
\nAnswer:<\/p>\n

def oddtoeven (L):\r\nfor i in range (len(L)):\r\nif (L[i]% 2! =0) :\r\nL [i]= L [i] * 2\r\nprint (L)<\/u><\/u><\/pre>\n

\"CBSE<\/p>\n

Question 21.
\nObserve the code and write the output. [2]<\/p>\n

'arihant publication'.count(\u2018hant', 0, 10)\r\n\"arihant\".isupper()<\/pre>\n

Or<\/p>\n

Observe the code and write the output.<\/p>\n

dic = {}\r\ndic [(1, 2, 4)] = 8\r\ndic [(4, 2, 1)] = 10\r\ndic [(1, 2)] = 24\r\nsum = 0\r\nfor i in die :\r\nsum = sum + dic [i]\r\nprint (sum)<\/pre>\n

Answer:
\n1 Or 42
\nFalse<\/p>\n

Question 22.
\nWrite about the terms degree and cardinality of a table. [2]<\/p>\n

Or<\/p>\n

Write a query on the Salespeople table, whose output will exclude all salespeople with a rating > = 100, unless they are located in Delhi. [2]
\nAnswer:
\nDegree It refers to the number of columns\/attributes in a table.
\nCardinality It refers to the number of rows\/records in a table.
\nA table Employee stores records of 10 employees in the following structure
\nEno Ename Dept Salary
\nThe degree of the table is 4.
\nThe cardinality of the table is 10.<\/p>\n

Or<\/p>\n

SELECT * FROM Salespeople WHERE NOT rating > = 100 OR city = \u2018Delhi\u2019;<\/pre>\n

Question 23.
\nObserve the following program and answer the question that follow; [2]<\/p>\n

import random x = 3\r\nN = random.randint (1, x)\r\nfor i in range (N):\r\nprint (i, #, i + 1)<\/pre>\n

What is the maximum and minimum number of times the loop will execute?
\nAnswer:
\nMaximum number = 3,
\nMinimum number = 1 \u2019<\/p>\n

Question 24.
\nFind the output of following code. [2]<\/p>\n

dic = (\u201cNitin\u201d : (21, \u201cNUT\u201d), \u201cAnkit\u201d : (15, \u201cNIIT\")} }\r\nprint(\u2018\u2018The original dictionary : \u201d, str(dic))\r\nresult = [(key, i, j) for key, (i, j) in dic.items( )]\r\nprint(\u201cThe list after conversion : \u201d, str(result))<\/pre>\n

Or<\/p>\n

What output will be generate when the following Python code is executed? [2]<\/p>\n

def ChangeList ( ):\r\nl = [ ]\r\nl1 = [ ]\r\nl2 = [ ]\r\nfor i in range (1, 10):\r\nl.append (i)\r\nfor i in range (10, 1, -2):\r\nl1.append (i)\r\nfor i in range (len (l1)):\r\nl2.append (l1 [i] + l[i])\r\nl2.append (len (l) - len (l1)\r\nprint (l2)\r\nChangeList ( )<\/pre>\n

Answer:
\nThe original dictionary : {\u2018Ankit\u2019 : (15, \u2018NIIT\u2019), \u2018Nitin\u2019 : (21, \u2018NIIT\u2019)}
\nThe list after conversion : [(\u2018Ankit\u2019, 15, \u2018NIIT\u2019), (\u2018Nitin\u2019, 21, ‘NIIT’)]<\/p>\n

Or<\/p>\n

Output
\n[11, 10, 9, 8, 7, 4]<\/p>\n

Question 25.
\nWhat is the output of the given code? [2]
\n(i) int(math.pow(2, 5))
\n(ii) print(math.pow(2, 5))
\nAnswer:
\n(i) 32
\n(ii) 32.0<\/p>\n

Section – C<\/span><\/p>\n

Question 26.
\nWrite the output for SQL queries (i) to (iii), which are based on the table ITEMS. [1 \u00d7 3 = 3]<\/p>\n

TABLE: ITEMS
\n\"CBSE
\n(i) SELECT MAX(Price), MIN(Price) FROM ITEMS:
\n(ii) SELECT Price * Qty AS AMOUNT FROM ITEMS WHERE Code=1004;
\n(iii) SELECT DISTINCT TCode FROM ITEMS;
\nAnswer:
\n\"CBSE<\/p>\n

Question 27.
\nWrite a function countEU() in Python, which should read each character of a text file IMP.TXT should count and display occurrence of alphabets E and U (including small cases e and u too). [3]
\ne.g. If the file content is as follows :
\nPinaky has gone to his friend\u2019s house.
\nHis friend\u2019s name is Ravya. Her house is 12 km from Pinaky\u2019s house.
\nThe countEU() function should display the output as
\nE : 8; U : 3<\/p>\n

Or<\/p>\n

Write a Python program to find the longest word in file \u201cstatus.txt\u201d. If contents of status.txt are Welcome to your one-step solutions for all your study, practice and assessment need for various competitive and recruitment examinations and school segment. We have been working tirelessly for over a decade to make sure that you have best in class study resources because you deserve SUCCESS AND NOTHING LESS…
\nOutput should be :
\nLongest word : examinations [3]
\nAnswer:<\/p>\n

def countEU( ):\r\nf=open(\u2018TMP.TXT\u201d)\r\ne=0\r\nu=0\r\nwhile True:\r\nl=f.readline( )\r\nif not l:\r\nbreak\r\nfor i in l:\r\nif (i==\u2018E\u2019 or i==\u2018e\u2019):\r\ne=e+1\r\nelif(i==\u2018U\u2019 or i==\u2018u\u2019):\r\nu=u+1\r\nprint(\u201cE :\u201d,e)\r\nprint(\u201cU :\u201d,u)\r\nf.closed ( )<\/pre>\n

Or<\/p>\n

def Longest( ):\r\nf=open(\"status.txt\u201d)\r\nwords=f.read( ).split( )\r\nmax_len=len(max(words, key=len))\r\nfor word in words:\r\nif(len(word)==max_len):\r\nprint(\u201cLongest word:\u201d,word)<\/pre>\n

\"CBSE<\/p>\n

Question 28.
\nConsider the following tables GARMENT and FABRIC. Write SQL commands for the statements (i)to(iii). [1 \u00d7 3 = 3]
\nTABLE: GARMENT
\n\"CBSE<\/p>\n

TABLE:FABRIC
\n\"CBSE<\/p>\n

(i) To display GCODE and DESCRIPTION of each GARMENT in descending order of GCODE.
\n(ii) To display the details of all the GARMENTS, which have READYDATE in between 08-DEC-07 and 16-JUN-08 (inclusive of both the dates).
\n(iii) To display the average PRICE of all the GARMENTS. Which are made up of FABRIC with FCODE as F03.
\nAnswer:
\n(i) SELECT GCODE, DESCRIPTION FROM GARMENT ORDER BY GCODE DESC;
\n(ii) SELECT*FROM GARMENT WHERE READYDATE BETWEEN \u201808-DEC-07\u2019 AND ’16-JUN-08\u2019 ;
\n(iii) SELECT AVG(PRICE) FROM GARMENT WHERE FCODE = \u2018F03\u2019; –<\/p>\n

Question 29.
\nWrite the definition of a function Reverse (x) in Python, to display the elements in reverse order such that each displayed element is the twice of the original element (element *2) of the List x in the following manner: [3]
\nExample :
\nIf List x contains 7 integers is as follows:<\/p>\n\n\n\n\n
x[0]<\/td>\nX[1]<\/td>\nX[2]<\/td>\nX[3]<\/td>\nX[4]<\/td>\nX[5]<\/td>\nX[6]<\/td>\n<\/tr>\n
4<\/td>\n8<\/td>\n7<\/td>\n5<\/td>\n6<\/td>\n2<\/td>\n10<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

After executing the function, the array content should be displayed as follows:<\/p>\n\n\n\n
20<\/td>\n4<\/td>\n12<\/td>\n10<\/td>\n14<\/td>\n16<\/td>\n8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Answer:<\/p>\n

def Reverse (x):\r\nfor i in range (len (x) - 1, -1, -1) :\r\nprint (x[i] *2)<\/pre>\n

Question 30.
\nJulie has created a dictionary containing names and marks as key value pairs of 6 students. Write a program, with separate user defined functions to perform the following operations
\nPush the keys (name of the student) of the dictionary into a stack, where the corresponding value (marks) is greater than 75. [3]
\nPop and display the content of the stack.
\nFor example If the sample content of the dictionary is as follows
\nR={“OM”:76, “JAI”:45, “BOB”:89, “ALI”:65, ‘\u2019ANU”:90, “TOM”:82}
\nThe output from the program should be TOM ANU BOB OM
\nAnswer:<\/p>\n

R={\"OM\": 76, \"JAI\":45, \"BOB\": 89. \"ALI\":65, \"ANU\u201d:90, \"TOM\": 82}\r\ndef PUSH(S, N):\r\nS.append(N)\r\ndef POP(S):\r\nif S!=[]:\r\nreturn S.pop( )\r\nelse:\r\nreturn None\r\nST=[ ]\r\nfor k in R:\r\nif R[k]>=75:\r\nPUSH(ST, k)\r\nwhile True:\r\nif ST!=[ ]:\r\nprint(POP(ST),end=\" \")\r\nelse:\r\nbreak<\/pre>\n

Section – D<\/span><\/p>\n

Question 31.
\nConsider the table MOVIEDETAILS given below [1 \u00d7 4 = 4]
\nTable : MOVIEDETAILS
\n\"CBSE
\nWrite statements to :
\n(a) Delete the records whose language is “English\u201d.
\n(b) Add a new record : \u201cM050\u201d, \u201cPalki\u201d, “Hindi\u201d, 5,”Amazon Prime\u201d.
\n(c) Add a new column “DAYS\u201d of type integer.
\n(d) Remove the column “RATING”.
\nAnswer:
\n(a) DELETE FROM MOVIEDETAILS WHERE LANGUAGE=\u201dENGLISH\u201d;
\n(b) INSERT INTO MOVIEDETAILS VALUES (\u201cM050\u201d, \u201cPalki\u201d,”Hindi\u201d, 5,\u201cAmazon Prime\u201d);
\n(c) ALTER TABLE MOVIEDETAILS ADD DAYS INTEGER;
\n(d) ALTER TABLE MOVIEDETAILS DROP RATING;<\/p>\n

Question 32.
\nWrite a program using following functions : [4]
\ngetInventory() Write code to accept as many inventory records and store them to the csv file Inventory.csv storing records of inventory as per following structure
\nPCode Invname Price Reorder
\nDisplay() To display the detail that store in Inventory.csv
\nAnswer:<\/p>\n

from csv import writer\r\ndef getlnventory( ):\r\nwith open(\"Inventory.csv \",\"a\",newline=\"\\n\") as f :\r\ndt = writer (f)\r\nwhile True:\r\npcode= int(input(\"Enter Inventory code:\"))\r\ninv_name = inputC'Enter inventory name:\")\r\nprice = eval (input(\"Enter Price: \u201d))\r\nrol = int(input(\"Enter reorder level:\"))\r\ndt.writerow([pcode,inv_name,price, rol])\r\nprint(\"Record has been added.\")\r\nprintC'Want to add more record?Type YES!!!\")\r\nch = input()\r\nch = ch.upper()\r\nif ch==\"YES\":\r\nprint (\"****************\")\r\nelse:\r\nbreak\r\ndef Display( ):\r\nf = open(\"Inventory.csv\",\"r\")\r\ndt = reader(f)\r\ndata = list(dt)\r\nf.close( )\r\nfor i in data:\r\nfor j in i:\r\nprint(\u2019\\t',j, end=\" \")\r\nprint( )\r\ngetInventory( )\r\nDisplay( )<\/pre>\n

Section – E<\/span><\/p>\n

Question 33.
\nRed Pandas Infosystems has its 4 blocks of buildings. The number of computers and distances among them is given below : [1 \u00d7 5 = 5]
\n\"CBSE<\/p>\n\n\n\n\n\n\n\n
Building<\/td>\nNumber of Computers<\/td>\n<\/tr>\n
HR<\/td>\n15<\/td>\n<\/tr>\n
ADMIN<\/td>\n100<\/td>\n<\/tr>\n
SYSTEM<\/td>\n25<\/td>\n<\/tr>\n
PERS<\/td>\n30<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

 <\/p>\n\n\n\n\n\n\n\n\n\n
Building<\/td>\nDistance<\/td>\n<\/tr>\n
HR-Admin<\/td>\n10m<\/td>\n<\/tr>\n
HR-System<\/td>\n50m<\/td>\n<\/tr>\n
HR-Pers<\/td>\n750m<\/td>\n<\/tr>\n
Admin-System<\/td>\n300m<\/td>\n<\/tr>\n
Admin-Pers<\/td>\n20m<\/td>\n<\/tr>\n
System-Pers<\/td>\n250m<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Answer the following questions with respect to the above :
\n(i) Suggest a suitable cable layout for the network.
\n(ii) Suggest the best place to house the server of the network.
\n(iii) Which topology should be used to connect computers in each building?
\n(iv) What kind of network will be formed here? (LAN\/MAN\/WAN)
\n(v) Write one advantage of the topology suggested by you.
\nAnswer:
\n(i) The cable layout is given below :
\n\"CBSE
\n(ii) ADMIN building, as it has the maximum number of computers.
\n(iii) Star topology, as it is the topology offering best facilities.
\n(iv) LAN – Local Area Network
\n(v) Fault detection is easy.<\/p>\n

\"CBSE<\/p>\n

Question 34.
\n(i) What is CSV file?\u00a0 [2 + 3 = 5]
\n(ii) Write a program using two functions :
\naddCustomer() To write Customer code, Customer name and Amt in file “cust.csv\u201d.
\nThe details of the customers are as follows :
\n[‘CustCode’, ‘CustName’, ‘Amount’]
\n[‘001’, ‘Nihir’, ‘8000’]
\n[‘104′, \u2019Akshay’, ‘5000’]
\nreadCustomer() To read the details of the customers and display them.<\/p>\n

Or<\/p>\n

(i) When do we use CSV file? [5]
\n(ii) A Binary file, STATUS.DAT has the following structure:
\n[BNO:[BNAME, BTYPE])
\nWhere,
\nBNO – Book Number
\nBNAME – Book Name
\nBTYPE is Book Type
\nWrite a user-defined function, selectType(btype), that accepts btype as parameter and displays all the records from the binary file STATUS.DAT, that have the value of Book Type as btype.
\nAnswer:
\n(i) CSV (Comma Separated Values) is a file format for data storage which looks like a text file.
\n(ii) import csv<\/p>\n

def addCustomer():\r\nf1 = open(\u2019cust.csv', 'w', newline = \"\\n\u201d)\r\nw1 = csv.writer(f1, delimiter = \u201d;\")\r\nw1.writerow(['CustCode', 'CustName', 'Amount'])\r\nw1.writerow(['001', 'Nihir', '8000'])\r\nw1.writerow(['104', 'Akshay', '5000'])\r\nf1.close( )\r\nreadCustomer( ):\r\nwith open(\"cust.csv\u201d, 'r',\u201c\\n\u201d) as file1:\r\nreader = csv. reader(file1, delimiter = \";\")\r\nfor row in reader:\r\nprint(row)\r\nfile1.close( )\r\naddCustomer( )\r\nreadCustomer()<\/pre>\n

Or<\/p>\n

(i) We can use CSV file when<\/p>\n

    \n
  • Data has a strict tabular structure.<\/li>\n
  • To transfer large data between programs.<\/li>\n
  • To import and export data.<\/li>\n<\/ul>\n

    (ii) import pickle<\/p>\n

    def selectType(btype):\r\nf1 = open(\"STATUS.DAT\", \"rb\u201d)\r\ntry:\r\nwhile True:\r\ndata = pickle.load (f1)\r\nif data [2] == btype:\r\nprint(\"Book number: \",data[0])\r\nprintC'Book Name : \", data[1])\r\nprint(\"Book type: \", data [2])\r\nexcept EOFError:\r\nf1.close( )<\/pre>\n

    Question 35.
    \n(i) Differentiate between DROP and DELETE commands of SQL. [1 + 4 = 5]
    \n(ii) Consider the table Student whose fields are
    \n\"CBSE
    \nWrite the Python code to update grade to \u2018A\u2019 for all these students who are getting more than 8 as points.
    \nThe table structure is as follows:
    \nScode : integer
    \nName : varchar
    \nAge : integer
    \nStrcde : integer
    \nPoints : integer
    \nGrade : varchar
    \nNote the following to establish the connection between Python and MySQL:
    \nHost: localhost
    \nUsername : Admin
    \nPassword : Admin@123
    \nThe table exists in MySQL database as: Student<\/p>\n

    Or<\/p>\n

    (i) Identify any two DML commands from the following and also explain.
    \nALTER, INSERT, UPDATE, DROP, CREATE<\/p>\n

    (ii) Consider the table MobileStock with following fields
    \nM_Id, M_Name, M_Qty, M_Supplier
    \nWrite tile Python code to fetch all records with fields M_Id, M_Name and MSupplier from database Mobile.
    \nConsider:
    \nhost: localhost
    \nUserName : root
    \nPassword : system
    \nDatabase : Mobile
    \nAnswer:
    \n(i) The DROP command removes the entire table with its structure and records. DELETE command is used to delete records of a table.<\/p>\n

    (ii)<\/p>\n

    import mysql.connector as mydb\r\ncon = mydb.connect (host = \u201clocalhost\u201d,\r\nuser = \u201cAdmin\u201d,\r\npasswd = \"Admin@123\u201d,\r\ndatabase = \"system\u201d)\r\ncursor = con.cursor ( )\r\nsql = \"UPDATE Student SET Grade = \u2018A\u2019\r\nWHERE Points > 8\u201d\r\ntry :\r\ncursor, execute (sql)\r\ncon.commit ( )\r\nexcept :\r\ncon.rollback ( )\r\ncon.close ( )<\/pre>\n

    Or<\/p>\n

    (i) INSERT, UPDATE
    \nThe INSERT command adds a record to a table.
    \nThe UPDATE command is used to change record(s) of a table.<\/p>\n

    (ii)<\/p>\n

    import mysql .connector as mydb\r\nmycon=mydb.connect (host = \u201clocalhost\u201d, user = \u201croot\u201d, passwd = \u201csystem\u201d, database = \u201cMobile\u201d)\r\ncursor = mycon.cursor ()\r\nsql = \u201cSELECT M_Id, M_Name, M_Supplier\r\nFROM MobileStock\u201d\r\ntry:\r\ncursor.execute (sql)\r\ndisplay = cursor, fetchall( )\r\nfor i in display:\r\nprint (i)\r\nexcept:\r\nmycon.rollback( )\r\nmycon.close()<\/pre>\n","protected":false},"excerpt":{"rendered":"

    Students must start practicing the questions from\u00a0CBSE Sample Papers for Class 12 Computer Science with Solutions Set 4 are designed as per the revised syllabus. CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions Time: 3 hrs Max. Marks: 70 Instructions 1. Please check this question paper contains 35 questions. 2. The […]<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":""},"categories":[84911],"tags":[],"yoast_head":"\nCBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions - Learn CBSE<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions\" \/>\n<meta property=\"og:description\" content=\"Students must start practicing the questions from\u00a0CBSE Sample Papers for Class 12 Computer Science with Solutions Set 4 are designed as per the revised syllabus. CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions Time: 3 hrs Max. Marks: 70 Instructions 1. Please check this question paper contains 35 questions. 2. The […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn CBSE\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ncertsolutionsbooks\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-02T06:50:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-02T09:12:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.learncbse.in\/wp-content\/uploads\/2023\/12\/Learn-CBSE.png\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:creator\" content=\"@learncbse\" \/>\n<meta name=\"twitter:site\" content=\"@learncbse\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sastry CBSE\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"16 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.learncbse.in\/#organization\",\"name\":\"LearnCBSE\",\"url\":\"https:\/\/www.learncbse.in\/\",\"sameAs\":[\"https:\/\/www.facebook.com\/ncertsolutionsbooks\/\",\"https:\/\/www.instagram.com\/learncbse.in\/\",\"https:\/\/www.youtube.com\/user\/CBSEPapers\",\"https:\/\/in.pinterest.com\/learncbsein\/\",\"https:\/\/twitter.com\/learncbse\"],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.learncbse.in\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.learncbse.in\/wp-content\/uploads\/2017\/01\/LearnCBSE.in_.png\",\"contentUrl\":\"https:\/\/www.learncbse.in\/wp-content\/uploads\/2017\/01\/LearnCBSE.in_.png\",\"width\":210,\"height\":198,\"caption\":\"LearnCBSE\"},\"image\":{\"@id\":\"https:\/\/www.learncbse.in\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.learncbse.in\/#website\",\"url\":\"https:\/\/www.learncbse.in\/\",\"name\":\"Learn CBSE\",\"description\":\"NCERT Solutions for Class 6, 7, 8, 9, 10, 11 and 12\",\"publisher\":{\"@id\":\"https:\/\/www.learncbse.in\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.learncbse.in\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.learncbse.in\/wp-content\/uploads\/2023\/12\/Learn-CBSE.png\",\"contentUrl\":\"https:\/\/www.learncbse.in\/wp-content\/uploads\/2023\/12\/Learn-CBSE.png\",\"width\":116,\"height\":16,\"caption\":\"Learn CBSE\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#webpage\",\"url\":\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/\",\"name\":\"CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions - Learn CBSE\",\"isPartOf\":{\"@id\":\"https:\/\/www.learncbse.in\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#primaryimage\"},\"datePublished\":\"2024-01-02T06:50:31+00:00\",\"dateModified\":\"2024-01-02T09:12:56+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.learncbse.in\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.learncbse.in\/#\/schema\/person\/61b9daccbdd8635544055b7568d50f43\"},\"headline\":\"CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions\",\"datePublished\":\"2024-01-02T06:50:31+00:00\",\"dateModified\":\"2024-01-02T09:12:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#webpage\"},\"wordCount\":2250,\"publisher\":{\"@id\":\"https:\/\/www.learncbse.in\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.learncbse.in\/wp-content\/uploads\/2023\/12\/Learn-CBSE.png\",\"articleSection\":[\"CBSE Sample Papers\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.learncbse.in\/#\/schema\/person\/61b9daccbdd8635544055b7568d50f43\",\"name\":\"Sastry CBSE\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.learncbse.in\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d97564d7fa0c644fd231068e890b0736?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d97564d7fa0c644fd231068e890b0736?s=96&d=mm&r=g\",\"caption\":\"Sastry CBSE\"},\"sameAs\":[\"http:\/\/www.recruitmenttopper.com\/\"],\"url\":\"https:\/\/www.learncbse.in\/author\/sastry-cbse\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions - Learn CBSE","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/","og_locale":"en_US","og_type":"article","og_title":"CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions","og_description":"Students must start practicing the questions from\u00a0CBSE Sample Papers for Class 12 Computer Science with Solutions Set 4 are designed as per the revised syllabus. CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions Time: 3 hrs Max. Marks: 70 Instructions 1. Please check this question paper contains 35 questions. 2. The […]","og_url":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/","og_site_name":"Learn CBSE","article_publisher":"https:\/\/www.facebook.com\/ncertsolutionsbooks\/","article_published_time":"2024-01-02T06:50:31+00:00","article_modified_time":"2024-01-02T09:12:56+00:00","og_image":[{"url":"https:\/\/www.learncbse.in\/wp-content\/uploads\/2023\/12\/Learn-CBSE.png"}],"twitter_card":"summary","twitter_creator":"@learncbse","twitter_site":"@learncbse","twitter_misc":{"Written by":"Sastry CBSE","Est. reading time":"16 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/www.learncbse.in\/#organization","name":"LearnCBSE","url":"https:\/\/www.learncbse.in\/","sameAs":["https:\/\/www.facebook.com\/ncertsolutionsbooks\/","https:\/\/www.instagram.com\/learncbse.in\/","https:\/\/www.youtube.com\/user\/CBSEPapers","https:\/\/in.pinterest.com\/learncbsein\/","https:\/\/twitter.com\/learncbse"],"logo":{"@type":"ImageObject","@id":"https:\/\/www.learncbse.in\/#logo","inLanguage":"en-US","url":"https:\/\/www.learncbse.in\/wp-content\/uploads\/2017\/01\/LearnCBSE.in_.png","contentUrl":"https:\/\/www.learncbse.in\/wp-content\/uploads\/2017\/01\/LearnCBSE.in_.png","width":210,"height":198,"caption":"LearnCBSE"},"image":{"@id":"https:\/\/www.learncbse.in\/#logo"}},{"@type":"WebSite","@id":"https:\/\/www.learncbse.in\/#website","url":"https:\/\/www.learncbse.in\/","name":"Learn CBSE","description":"NCERT Solutions for Class 6, 7, 8, 9, 10, 11 and 12","publisher":{"@id":"https:\/\/www.learncbse.in\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.learncbse.in\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#primaryimage","inLanguage":"en-US","url":"https:\/\/www.learncbse.in\/wp-content\/uploads\/2023\/12\/Learn-CBSE.png","contentUrl":"https:\/\/www.learncbse.in\/wp-content\/uploads\/2023\/12\/Learn-CBSE.png","width":116,"height":16,"caption":"Learn CBSE"},{"@type":"WebPage","@id":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#webpage","url":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/","name":"CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions - Learn CBSE","isPartOf":{"@id":"https:\/\/www.learncbse.in\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#primaryimage"},"datePublished":"2024-01-02T06:50:31+00:00","dateModified":"2024-01-02T09:12:56+00:00","breadcrumb":{"@id":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.learncbse.in\/"},{"@type":"ListItem","position":2,"name":"CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions"}]},{"@type":"Article","@id":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#article","isPartOf":{"@id":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#webpage"},"author":{"@id":"https:\/\/www.learncbse.in\/#\/schema\/person\/61b9daccbdd8635544055b7568d50f43"},"headline":"CBSE Sample Papers for Class 12 Computer Science Set 4 with Solutions","datePublished":"2024-01-02T06:50:31+00:00","dateModified":"2024-01-02T09:12:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#webpage"},"wordCount":2250,"publisher":{"@id":"https:\/\/www.learncbse.in\/#organization"},"image":{"@id":"https:\/\/www.learncbse.in\/cbse-sample-papers-for-class-12-computer-science-set-4\/#primaryimage"},"thumbnailUrl":"https:\/\/www.learncbse.in\/wp-content\/uploads\/2023\/12\/Learn-CBSE.png","articleSection":["CBSE Sample Papers"],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.learncbse.in\/#\/schema\/person\/61b9daccbdd8635544055b7568d50f43","name":"Sastry CBSE","image":{"@type":"ImageObject","@id":"https:\/\/www.learncbse.in\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/d97564d7fa0c644fd231068e890b0736?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d97564d7fa0c644fd231068e890b0736?s=96&d=mm&r=g","caption":"Sastry CBSE"},"sameAs":["http:\/\/www.recruitmenttopper.com\/"],"url":"https:\/\/www.learncbse.in\/author\/sastry-cbse\/"}]}},"_links":{"self":[{"href":"https:\/\/www.learncbse.in\/wp-json\/wp\/v2\/posts\/156293"}],"collection":[{"href":"https:\/\/www.learncbse.in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.learncbse.in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.learncbse.in\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.learncbse.in\/wp-json\/wp\/v2\/comments?post=156293"}],"version-history":[{"count":12,"href":"https:\/\/www.learncbse.in\/wp-json\/wp\/v2\/posts\/156293\/revisions"}],"predecessor-version":[{"id":156357,"href":"https:\/\/www.learncbse.in\/wp-json\/wp\/v2\/posts\/156293\/revisions\/156357"}],"wp:attachment":[{"href":"https:\/\/www.learncbse.in\/wp-json\/wp\/v2\/media?parent=156293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.learncbse.in\/wp-json\/wp\/v2\/categories?post=156293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.learncbse.in\/wp-json\/wp\/v2\/tags?post=156293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}