Back to papers
CBSE · 083Class XII

Computer Science · 2024

2 April 2024 · Main paper

Questions
35
Total marks
70
Sections
5
A

Section A

18 q · 18 marks
01

State True or False : While defining a function in Python, the positional parameters in the function header must always be written after the default parameters.

[1]
Answer

False

Explanation

Positional parameters must be defined before default parameters in a function header.

02

The SELECT statement when combined with _____ clause, returns records without repetition.

[1]
Answer

(a) DISTINCT

Explanation

The DISTINCT clause is used in SQL to return only distinct (different) values.

03

What will be the output of the following statement : print (16*5/4*2/5-8)

[1]
Answer

(c) 0.0

Explanation

The expression evaluates as: 16*5=80, 80/4=20.0, 20.0*2=40.0, 40.0/5=8.0, 8.0-8=0.0.

04

What possible output from the given options is expected to be displayed when the following Python code is executed ?

python
import random
Signal = ['RED', 'YELLOW', 'GREEN']
for K in range(2, 0, -1) :
    R = random.randrange(K)
    print(Signal[R], end = '#')
[1]
Answer

(a) YELLOW # RED #

Explanation

The loop runs for K=2 and K=1. For K=2, R is 0 or 1. For K=1, R is 0. 'YELLOW # RED #' is a possible output.

05

In SQL, the aggregate function which will display the cardinality of the table is ______ .

[1]
Answer

(b) count(*)

Explanation

Cardinality refers to the number of rows in a table, which is returned by count(*).

06

Which protocol out of the following is used to send and receive emails over a computer network ?

[1]
Answer

(d) SMTP

Explanation

SMTP (Simple Mail Transfer Protocol) is the standard protocol for sending emails.

07

Identify the invalid Python statement from the following :

[1]
Answer

(d) g = dict{}

Explanation

dict{} is invalid syntax because {} denotes a set or dict literal, while dict() is the constructor. It should be g = {} or g = dict().

08

Consider the statements given below and then choose the correct output from the given options :

python
myStr = "MISSISSIPPI"
print(myStr[:4]+"#"+myStr[-5:])
[1]
Answer

(b) MISS#SIPPI

Explanation

myStr[:4] gives 'MISS' and myStr[-5:] gives 'SIPPI'. Concatenating them with '#' gives 'MISS#SIPPI'.

09

Identify the statement from the following which will raise an error :

[1]
Answer

(c) print("15" + 3)

Explanation

Python does not support implicit type coercion for addition between a string ('15') and an integer (3).

10

Select the correct output of the following code :

python
event = "G20 Presidency@2023"
L = event.split(' ')
print(L[::-2])
[1]
Answer

(b) ['Presidency@2023']

Explanation

split creates ['G20', 'Presidency@2023']. Slicing [::-2] reverses it and takes every second element, resulting in ['Presidency@2023'].

11

Which of the following options is the correct unit of measurement for network bandwidth ?

[1]
Answer

(c) Hz

Explanation

Bandwidth is measured in Hertz (Hz), representing the range of frequencies used for transmission.

12

Observe the given Python code carefully :

python
a = 20
def convert(a):
    b = 20
    a = a + b
convert(10)
print(a)

Select the correct output from the given options :

[1]
Answer

(b) 20

Explanation

The variable 'a' inside the function is local and does not affect the global variable 'a', which remains 20.

13

State whether the following statement is True or False : While handling exceptions in Python, name of the exception has to be compulsorily added with except clause.

[1]
Answer

False

Explanation

A bare 'except:' clause can be used to catch all exceptions without specifying a name.

14

Which of the following is not a DDL command in SQL ?

[1]
Answer

(c) UPDATE

Explanation

UPDATE is a DML (Data Manipulation Language) command, not a DDL (Data Definition Language) command.

15

Fill in the blank : ________ is a set of rules that needs to be followed by the communicating parties in order to have a successful and reliable data communication over a network.

[1]
Answer

Protocol

Explanation

A protocol defines the rules and conventions for communication between network devices.

16

Consider the following Python statement : F=open('CONTENT.TXT') Which of the following is an invalid statement in Python ?

[1]
Answer

(c) F.seek(0,-1)

Explanation

F.seek(0,-1) is invalid because the reference point (whence) cannot be negative.

17

Assertion (A) : CSV file is a human readable text file where each line has a number of fields, separated by comma or some other delimiter. Reason (R) : writerow() method is used to write a single row in a CSV file.

[1]
Answer

(b) Both (A) and (R) are true and (R) is not the correct explanation for (A).

Explanation

Both statements are factually correct, but the use of writerow() is not the reason why CSV files are human-readable.

18

Assertion (A) : The expression "Hello".sort() in Python will give an error. Reason (R) : sort() does not exist as a method/function for strings in Python.

[1]
Answer

(a) Both (A) and (R) are true and (R) is the correct explanation for (A).

Explanation

Strings in Python are immutable and do not have a sort() method; they use sorted().

B

Section B

15 q · 22 marks
19i

Expand the following terms : XML ,PPP

[1]
Answer

XML: eXtensible Markup Language PPP: Point-to-Point Protocol

Explanation

XML stands for eXtensible Markup Language. PPP stands for Point-to-Point Protocol.

19ii

Give one difference between circuit switching and packet switching.

[1]
Answer

Circuit Switching establishes a dedicated path; Packet Switching splits data into packets sent independently.

Explanation

Circuit switching reserves a dedicated channel for the duration of the communication. Packet switching routes data in small packets independently.

19i(or)

Define the term web hosting.

[1]
Answer

Web hosting is a service that allows organizations and individuals to post a website or web page onto the Internet.

Explanation

It provides the technologies and services needed for the website or webpage to be viewed in the Internet.

19ii(or)

Name any two web browsers.

[1]
Answer

Google Chrome, Mozilla Firefox

Explanation

Examples of web browsers include Google Chrome, Mozilla Firefox, Safari, and Microsoft Edge.

20

The code given below accepts five numbers and displays whether they are even or odd : Observe the following code carefully and rewrite it after removing all syntax and logical errors : Underline all the corrections made.

python
def EvenOdd()
    for i in range(5) :
        num=int(input("Enter a number")
        if num/2==0:
            print("Even")
        else:
        print("Odd")
EvenOdd()
[2]
Answer
python
def EvenOdd():                            # Error 1: added colon
    for i in range(5):
        num = int(input("Enter a number"))  # Error 2: closed parenthesis
        if num % 2 == 0:                     # Error 3: / changed to %
            print("Even")
        else:
            print("Odd")                     # Error 4: indented under else
EvenOdd()
Explanation

Four corrections: (1) colon after def header, (2) missing closing parenthesis on input(), (3) num/2==0 changed to num%2==0 for an even-number check, (4) print("Odd") indented inside the else block.

21

Write a user defined function in Python named showGrades(S) which takes the dictionary S as an argument. The dictionary, S contains Name:[Eng,Math,Science] as key:value pairs. The function displays the corresponding grade obtained by the students according to the following grading rules :

Average of Eng,Math,ScienceGrade
>=90A
<90 but >=60B
<60C

For example : Consider the following dictionary

python
S = {"AMIT":[92,86,64], "NAGMA":[65,42,43], "DAVID":[92,90,88]}

The output should be :

text
AMIT - B
NAGMA - C
DAVID - A
[2]
Answer
python
def showGrades(S):
    for K, V in S.items():
        if sum(V)/3 >= 90:
            Grade = "A"
        elif sum(V)/3 >= 60:
            Grade = "B"
        else:
            Grade = "C"
        print(K, "-", Grade)
Explanation

Iterates through the dictionary items, computes the average of each value list, and prints the corresponding grade.

21(or)

Write a user defined function in Python named Puzzle(W,N) which takes the argument W as an English word and N as an integer and returns the string where every Nth alphabet of the word W is replaced with an underscore ("_").

For example : if W contains the word "TELEVISION" and N is 3, then the function should return the string "TE_EV_SI_N". Likewise for the word "TELEVISION" if N is 4, then the function should return "TEL_VIS_ON".

[2]
Answer
python
def Puzzle(W, N):
    NewW = ""
    for i in range(len(W)):
        if (i + 1) % N == 0:
            NewW += "_"
        else:
            NewW += W[i]
    return NewW

print(Puzzle("TELEVISION", 3))
Explanation

Iterates through the characters of W. If the 1-based index is a multiple of N, append '_'; otherwise append the original character.

22

Write the output displayed on execution of the following Python code :

python
LS = ["HIMALAYA", "NILGIRI", "ALASKA", "ALPS"]
D = {}
for S in LS:
    if len(S) % 4 == 0:
        D[S] = len(S)
for K in D:
    print(K, D[K], sep="#")
[2]
Answer
text
HIMALAYA#8
ALPS#4
Explanation

HIMALAYA has length 8 (8%4==0) and ALPS has length 4 (4%4==0). They are added to the dictionary and printed.

23aii

(ii) To display the number of occurrences of the substring "is" in a string named message. For example, if the string message contains "This is his book", then the output will be 3.

[1]
Answer
python
print(message.count("is"))
24a

Ms. Veda created a table named Sports in a MySQL database, containing columns Game_id, P_Age and G_name. After creating the table, she realized that the attribute, Category has to be added. Help her to write a command to add the Category column. Thereafter, write the command to insert the following record in the table:

Game_id : G42 P_Age : Above 18 G_name : Chess Category : Senior

[2]
Answer
python
ALTER TABLE Sports ADD Category VARCHAR(20);
INSERT INTO Sports VALUES('G42', 'Above 18', 'Chess', 'Senior');
Explanation

ALTER TABLE adds the new column. INSERT INTO adds the new row with the specified values.

24bi(or)

Write the SQL commands to perform the following tasks: (i) View the list of tables in the database, Exam.

[1]
Answer

SHOW TABLES;

Explanation

The SHOW TABLES command lists all tables in the currently selected database.

24bii(or)

(ii) View the structure of the table, Term1.

[1]
Answer

DESCRIBE Term1;

Explanation

The DESCRIBE (or DESC) command displays the structure (columns, types) of a table.

25

Predict the output of the following code :

python
def callon(b=20, a=10):
    b = b + a
    a = b - a
    print(b, "#", a)
    return b

x = 100
y = 200
x = callon(x, y)
print(x, "@", y)
y = callon(y)
print(x, "@", y)
[2]
Answer
text
300 # 100
300 @ 200
210 # 200
300 @ 210
Explanation

First call: b=100+200=300, a=300-200=100, returns 300 (assigned to x). Second call uses default a=10: b=200+10=210, a=210-10=200, returns 210 (assigned to y).

23ai

Write the Python statement for each of the following tasks using built-in functions/methods only :

(i) To remove the item whose key is "NISHA" from a dictionary named Students. For example, if the dictionary Students contains {"ANITA":90, "NISHA":76, "ASHA":92}, then after removal the dictionary should contain {"ANITA":90, "ASHA":92}.

[1]
Answer
python
Students.pop("NISHA")
# OR
del Students["NISHA"]
23b

A tuple named subject stores the names of different subjects. Write the Python commands to convert the given tuple to a list and thereafter delete the last element of the list.

[2]
Answer
python
subject = list(subject)
subject.pop()
# OR
subject = list(subject)
del subject[-1]
C

Section C

6 q · 18 marks
26

Write the output on execution of the following Python code :

python
S = "Racecar Car Radar"
L = S.split()
for W in L:
    x = W.upper()
    if x == x[::-1]:
        for I in x:
            print(I, end="*")
    else:
        for I in W:
            print(I, end="#")
    print()
[3]
Answer
text
R*A*C*E*C*A*R*
C#a#r#
R*A*D*A*R*
Explanation

'Racecar' and 'Radar' uppercase to palindromes (printed letter-by-letter with *). 'Car' is not a palindrome, so its original-case letters are printed with #.

27

Consider the table ORDERS given below and write the output of the SQL queries that follow :

ORDNOITEMQTYRATEORDATE
1001RICE231202023-09-10
1002PULSES131202023-10-18
1003RICE251102023-11-17
1004WHEAT28652023-12-25
1005PULSES161102024-01-15
1006WHEAT27552024-04-15
1007WHEAT25602024-04-30

(i) SELECT ITEM, SUM(QTY) FROM ORDERS GROUP BY ITEM; (ii) SELECT ITEM, QTY FROM ORDERS WHERE ORDATE BETWEEN '2023-11-01' AND '2023-12-31'; (iii) SELECT ORDNO, ORDATE FROM ORDERS WHERE ITEM = 'WHEAT' AND RATE>=60;

[3]
Answer

(i)

ITEMSUM(QTY)
RICE48
PULSES29
WHEAT80

(ii)

ITEMQTY
RICE25
WHEAT28

(iii)

ORDNOORDATE
10042023-12-25
10072024-04-30
Explanation

(i) Sums QTY grouped by ITEM. (ii) Filters by ORDATE within Nov–Dec 2023. (iii) Filters WHEAT rows with RATE>=60.

28

Write a user defined function in Python named showInLines() which reads contents of a text file named STORY.TXT and displays every sentence in a separate line. Assume that a sentence ends with a full stop (.), a question mark (?), or an exclamation mark (!).

For example, if the content of file STORY.TXT is as follows :

text
Our parents told us that we must eat vegetables to be healthy.And it turns out, our parents were right! So, what else did our parents tell?

Then the function should display the file's content as follows :

text
Our parents told us that we must eat vegetables to be healthy.
And it turns out, our parents were right!
So, what else did our parents tell?
[3]
Answer
python
def showInLines():
    with open("STORY.TXT", 'r') as F:
        content = F.read()
    sentence = ""
    for ch in content:
        sentence += ch
        if ch in "." + "?" + "!":
            print(sentence)
            sentence = ""
    if sentence:
        print(sentence)
Explanation

Builds up a sentence character by character; whenever a terminator (., ?, !) is hit, the accumulated sentence is printed on its own line and the buffer resets.

28(or)

Write a function, c_words() in Python that separately counts and displays the number of uppercase and lowercase alphabets in a text file, Words.txt.

[3]
Answer
python
def c_words():
    f = open("Words.txt", "r")
    Txt = f.read()
    CUpper = 0
    CLower = 0
    for ch in Txt:
        if ch.isupper():
            CUpper += 1
        elif ch.islower():
            CLower += 1
    print("Uppercase:", CUpper, "Lowercase:", CLower)
    f.close()
Explanation

Iterates the file content using isupper() and islower() to count characters of each case.

29

Consider the table Projects given below :

Table : Projects

P_idPnameLanguageStartdateEnddate
P001School Management SystemPython2023-01-122023-04-03
P002Hotel Management SystemC++2022-12-012023-02-02
P003Blood BankPython2023-02-112023-03-02
P004Payroll Management SystemPython2023-03-122023-06-02

Based on the given table, write SQL queries for the following : (i) Add the constraint, primary key to column P_id in the existing table Projects. (ii) To change the language to Python of the project whose id is P002. (iii) To delete the table Projects from MySQL database along with its data.

[3]
Answer

(i) ALTER TABLE Projects ADD PRIMARY KEY (P_id);

(ii) UPDATE Projects SET Language='Python' WHERE P_id='P002';

(iii) DROP TABLE Projects;

Explanation

(i) Adds the PRIMARY KEY constraint to P_id. (ii) Updates Language to 'Python' for P002. (iii) Drops the entire table along with its data.

30

Consider a list named Nums which contains random integers. Write the following user defined functions in Python and perform the specified operations on a stack named BigNums. (i) PushBig() : It checks every number from the list Nums and pushes all such numbers which have 5 or more digits into the stack, BigNums. (ii) PopBig() : It pops the numbers from the stack, BigNums and displays them. The function should also display "Stack Empty" when there are no more numbers left in the stack.

For example, if the list Nums contains the following data:

python
Nums = [213, 10025, 167, 254923, 14, 1297653, 31498, 386, 92765]

Then on execution of PushBig(), the stack BigNums should store:

text
[10025, 254923, 1297653, 31498, 92765]

And on execution of PopBig(), the following output should be displayed:

text
92765
31498
1297653
254923
10025
Stack Empty
[3]
Answer
python
def PushBig(Nums, BigNums):
    for N in Nums:
        if len(str(N)) >= 5:
            BigNums.append(N)

def PopBig(BigNums):
    while BigNums:
        print(BigNums.pop())
    print("Stack Empty")
Explanation

PushBig appends every number with 5 or more digits. PopBig pops and prints until empty, then displays 'Stack Empty'.

D

Section D

2 q · 8 marks
31

Consider the tables Admin and Transport given below :

Table : Admin

S_idS_nameAddressS_type
S001SandhyaRohiniDay Boarder
S002VedanshiRohtakDay Scholar
S003VibhuRaj NagarNULL
S004AtharvaRampurDay Boarder

Table : Transport

S_idBus_noStop_name
S002TSS10Sarai Kale Khan
S004TSS12Sainik Vihar
S005TSS10Kamla Nagar

Write SQL queries for the following : (i) Display the student name and their stop name from the tables Admin and Transport. (ii) Display the number of students whose S_type is not known. (iii) Display all details of the students whose name starts with 'V'. (iv) Display student id and address in alphabetical order of student name, from the table Admin.

[4]
Answer

(i) SELECT S_name, Stop_name FROM Admin, Transport WHERE Admin.S_id = Transport.S_id;

(ii) SELECT COUNT(*) FROM Admin WHERE S_type IS NULL;

(iii) SELECT * FROM Admin WHERE S_name LIKE 'V%';

(iv) SELECT S_id, Address FROM Admin ORDER BY S_name;

Explanation

(i) Equi-join on S_id. (ii) IS NULL counts unknown S_type. (iii) LIKE 'V%' matches names starting with V. (iv) ORDER BY sorts alphabetically.

32

Sangeeta is a Python programmer working in a computer hardware company. She has to maintain the records of the peripheral devices. She created a csv file named Peripheral.csv, to store the details.

The structure of Peripheral.csv is:

text
[P_id, P_name, Price]

where: - P_id is Peripheral device ID (integer) - P_name is Peripheral device name (String) - Price is Peripheral device price (integer)

Write user defined functions : - Add_Device() : to accept a record from the user and add it to a csv file, Peripheral.csv. - Count_Device() : to count and display number of peripheral devices whose price is less than 1000.

[4]
Answer
python
import csv

def Add_Device():
    F = open("Peripheral.csv", "a", newline='')
    W = csv.writer(F)
    P_id = int(input("Enter the Peripheral ID: "))
    P_name = input("Enter Peripheral Name: ")
    Price = int(input("Enter Price: "))
    W.writerow([P_id, P_name, Price])
    F.close()

def Count_Device():
    F = open("Peripheral.csv", "r")
    L = list(csv.reader(F))
    Count = 0
    for D in L:
        if int(D[2]) < 1000:
            Count += 1
    print(Count)
    F.close()
Explanation

Add_Device appends a new row in append mode. Count_Device reads all rows and counts those with Price < 1000.

E

Section E

9 q · 25 marks
34

(i) Differentiate between 'w' and 'a' file modes in Python.

(ii) Consider a binary file, items.dat, containing records stored in the given format:

text
{item_id: [item_name, amount]}

Write a function, Copy_new(), that copies all records whose amount is greater than 1000 from items.dat to new_items.dat.

[5]
Answer

(i) 'w' mode opens a file for writing. If the file does not exist, a new file is created. If it exists, its contents are truncated and replaced. The file pointer is positioned at the beginning.

'a' mode opens a file for appending. If the file does not exist, a new file is created. If it exists, the contents are preserved and the file pointer is placed at the end so new data is added after existing data.

(ii)

python
import pickle

def Copy_new():
    try:
        F1 = open("items.dat", "rb")
        F2 = open("new_items.dat", "wb")
        try:
            while True:
                D1 = pickle.load(F1)
                for K, V in D1.items():
                    if V[1] > 1000:
                        pickle.dump({K: V}, F2)
        except EOFError:
            pass
        F1.close()
        F2.close()
    except:
        print("File Opening Error")
Explanation

(i) 'w' truncates existing content; 'a' preserves and appends. (ii) Reads each pickled record, checks amount index [1], and writes qualifying records to the new file.

34(or)

(i) What is the advantage of using with clause while opening a data file in Python ? Also give syntax of with clause.

(ii) A binary file, EMP.DAT has the following structure:

text
[Emp_Id, Name, Salary]

where - Emp_Id : Employee id - Name : Employee Name - Salary : Employee Salary

Write a user defined function, disp_Detail(), that would read the contents of the file EMP.DAT and display the details of those employees whose salary is below 25000.

[5]
Answer

(i) The advantage of using the with clause is that any file opened using it is closed automatically once control leaves the with block — even if an exception is raised.

Syntax:

python
with open(file_name, access_mode) as file_object:
    # operations

Example:

python
with open("myfile.txt", "r+") as file_object:
    content = file_object.read()

(ii)

python
import pickle

def disp_Detail():
    try:
        with open("EMP.DAT", "rb") as F:
            try:
                while True:
                    Data = pickle.load(F)
                    if Data[2] < 25000:
                        print(Data)
            except EOFError:
                pass
    except:
        print("File Not Found!!!")
Explanation

(i) The 'with' clause auto-closes files and handles cleanup. (ii) Loops through pickled records, filters by Salary index [2] < 25000.

35

(i) Define Cartesian Product with respect to RDBMS.

(ii) Sunil wants to write a program in Python to update the quantity to 20 of the records whose item code is 111 in the table named shop in MySQL database named Keeper. The table shop in MySQL contains the following attributes: - Item_code: Item code (Integer) - Item_name: Name of item (String) - Qty: Quantity of item (Integer) - Price: Price of item (Integer)

Consider the following to establish connectivity between Python and MySQL: - Username: admin - Password: Shopping - Host: localhost

[5]
Answer

(i) Cartesian Product is an operation that combines rows/tuples from two tables/relations. It results in all possible pairs of rows from both tables and is denoted by 'X'. If table A has m rows and table B has n rows, the Cartesian product has m × n rows.

(ii)

python
import pymysql as pm

DB = pm.connect(host="localhost", user="admin",
                passwd="Shopping", database="Keeper")
MyCursor = DB.cursor()
MyCursor.execute("UPDATE shop SET Qty=20 WHERE Item_code=111")
DB.commit()
DB.close()
Explanation

(i) Defines the cross-product relational operation. (ii) Connects to MySQL via pymysql, executes the UPDATE, commits, and closes.

33i

Infotainment Ltd. is an event management company with its prime office located in Bengaluru. The company is planning to open its new division at three different locations in Chennai named as - Vajra, Trishula and Sudershana. You, as a networking expert need to suggest solutions to the questions in part (i) to (v), keeping in mind the distances and other given parameters.

Distances between various locations:

From - ToDistance
Vajra to Trishula350 m
Trishula to Sudershana415 m
Sudershana to Vajra300 m
Bengaluru Office to Chennai2000 km

Number of Computers installed at various locations:

LocationComputers
Vajra120
Sudershana75
Trishula65
Bengaluru Office250

(i) Suggest and draw the cable layout to efficiently connect various locations in Chennai division for connecting the digital devices.

[1]
Answer

Star topology connecting Trishula and Sudershana to Vajra.

Explanation

Star topology centered at Vajra minimises cable length given the distances.

33ii

(ii) Which block in Chennai division should host the server ? Justify your answer.

[1]
Answer

Vajra can host the server, as it has the maximum number of computers (120).

Explanation

Placing the server at the block with the largest user base reduces network traffic and cabling costs.

33iii

(iii) Which fast and effective wired transmission medium should be used to connect the prime office at Bengaluru with the Chennai division ?

[1]
Answer

Optical Fiber

Explanation

Optical fiber provides high bandwidth and low attenuation, suitable for long-distance (~2000 km) wired links.

33iv

(iv) Which network device will be used to connect the digital devices within each location of Chennai division so that they may communicate with each other ?

[1]
Answer

Switch (or Hub / Router)

Explanation

Switches connect multiple devices within a LAN segment.

33v

(v) A considerable amount of data loss is noticed between the different locations of the Chennai division, which are connected in the network. Suggest a networking device that should be installed to refresh the data and reduce the data loss during transmission to and from different locations of Chennai division.

[1]
Answer

Repeater

Explanation

A repeater regenerates weakened signals over long cable runs, reducing data loss.

35(or)

(i) Give any two features of SQL.

(ii) Sumit wants to write a code in Python to display all the details of the passengers from the table flight in MySQL database, Travel. The table contains the following attributes: - F_code: Flight code (String) - F_name: Name of flight (String) - Source: Departure city of flight (String) - Destination: Destination city of flight (String)

Consider the following to establish connectivity between Python and MySQL: - Username: root - Password: airplane - Host: localhost

[5]
Answer

(i) Any two of the following: - Full form is Structured Query Language. - Is used to retrieve and view specific data from a table in a database. - Is case insensitive. - Each query in SQL ends with a semicolon (;). - It contains DDL and DML.

(ii)

python
import pymysql as pm

DB = pm.connect(host="localhost", user="root",
                password="airplane", database="Travel")
MyCursor = DB.cursor()
MyCursor.execute("SELECT * FROM flight")
Rec = MyCursor.fetchall()
for R in Rec:
    print(R)
DB.close()
Explanation

(i) Two acceptable SQL feature statements. (ii) Connects to MySQL, executes SELECT, fetches all rows, and prints them.

End of paper
Source · CBSE Class XII Computer Science (083) · 2024