0% found this document useful (0 votes)
22 views7 pages

Ch1 Ch2 Selected Questions

Uploaded by

Vedantika saini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views7 pages

Ch1 Ch2 Selected Questions

Uploaded by

Vedantika saini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Class 12 Informatics Practices

Chapter 1 & 2 Selected Questions


2 The purpose of WHERE clause in a SQL statement is to:
(A) Create a table
(B) Filter rows based on a specific condition
(C) Specify the columns to be displayed
(D) Sort the result based on a column 1

4 Identify the SQL command used to delete a relation (table) from a relational
database.
(A) DROP TABLE
(B) REMOVE TABLE
(C) DELETE TABLE
(D) ERASE TABLE 1

6 Which of the following Python statements can be used to select a column


column_name from a DataFrame df ?
(A) df.getcolumn('column_name')
(B) df['column_name']
(C) df.select('column_name')
(D) df(column_name) 1

8 State whether the following statement is True or False:


In SQL, the HAVING clause is used to apply filter on groups formed by the GROUP
BY clause. 1

9 Which of the following Python statements is used to import data from a CSV file
into a Pandas DataFrame (Note: pd is an alias for pandas)?
(A) pd.open_csv('filename.csv')
(B) pd.read_csv('filename.csv')
(C) pd.load_csv('filename.csv')
(D) pd.import_csv('filename.csv') 1

11 Fill in the Blank


The COUNT(*) function provides the total number of __________ within a
relation (table) in a relational database .
(A) Columns
(B) Unique values
(C) Not-null values
(D) Rows 1

13 In a Pandas DataFrame, if the tail() function is used without specifying the


optional argument indicating the number of rows to display, what is the default
number of rows displayed , considering the DataFrame has 10 entries?
(A) 0
(B) 1
(C) 4
(D) 5 1

15 While creating a Series using a dictionary, the keys of the dictionary become:
(A) Values of the Series 1
Page 4 of 14
(B) Indices of the Series
(C) Data type of the Series
(D) Name of the Series

16 Match the following SQL functions /clauses with their descriptions:


SQL Function Description
P. MAX() 1. Find the position of a substring in a string.
Q. SUBSTRING() 2. Returns the maximum value in a column.
R. INSTR() 3. Sorts the data based on a column.
S. ORDER BY 4. Extracts a portion of a string.

(A) P-2, Q-4, R-3, S-1


(B) P-2, Q-4, R-1, S-3
(C) P-4, Q-3, R-2, S-1
(D) P-4, Q-2, R-1, S-3 1

17 Fill in the Blank


Boolean indexing in Pandas DataFrame can be used for _______.
(A) Creating a new DataFrame
(B) Sorting data based on index labels
(C) Joining data using labels
(D) Filtering data based on condition 1

20 Assertion (A): We can add a new column in an existing DataFrame.


Reason (R): DataFrames are size mutable. 1

21 Assertion (A): In SQL, INSERT INTO is a Data Definition Language (DDL)


Command.
Reason (R): DDL commands are used to create, modify, or remove database
structures, such as tables. 1

22 (A)

(B) What is a Series in Python Pandas? Also, give a suitable example to support
your answer.
OR
What does the term 'library' signify in Python? Mention one use for each of
the following libraries:
• Pandas
• Matplotlib 2

24 Consider the string: "Database Management System ". Write suitable SQL
queries for the following:
I. To extract and display "Manage " from the string.
II. Display the position of the first occurrence of "base " in the given string. 2

26 Define the term Primary Key in a database. Explain how it is different from a
Candidate Key. 2

28 (A)
(B) Sneha is writing a Python program to create a DataFrame using a list of
dictionaries. However, her code contains some mistakes. Identify the errors,
rewrite the correct code, and underline the corrections made.
import Pandas as pd
D1 = {'Name': 'Rakshit', 'Age': 25}
D2 = {'Name': 'Paul', 'Age': 30}
D3 = {'Name': 'Ayesha", 'Age': 28}
data = [D1,D2,D3)
df = pd.Dataframe(data)
print(df)
OR
Complete the given Python code to get the required output (ignore the dtype
attribute) as
Output:
Tamil Nadu Chennai
Uttar Pradesh Lucknow
Manipur Imphal

Code:
import _______ as pd
data = ['Chennai','_______','Imphal']
indx = ['Tamil Nadu','Uttar Pradesh','Manipur']
s = pd.Series(_______, indx)
print(_______) 2

30 (A)

(B) Write a Python program to create the following DataFrame using a list of
dictionaries.
Product Price

2 Monitor 15000

31 I. Write an SQL statement to create a table named STUDENTS , with the


following specifications:

II. Write SQL Query to insert the following data in the Student s Table
1, Supriya, Singh, 2010 -08-18, 75.5 Column Name Data Type Key
StudentID Numeric Primary Key
FirstName Varchar(20)
LastName Varchar(10)
DateOfBirth Date
Percentage Float(10,2) 2+1= 3

2 KABIR FARIDABAD

4 PAUL SEOUL

2 SALES ASSOCIATE 50000

4 ENGINEERING ENGINEER 70000

33 During a practical exam, a student Ankita has to fill in the blanks in a Python
program that generates a bar chart. This bar chart represents the number of
books read by four students in one month.
Student Name Books
Read
Karan 12
Lina 9
Raj 5
Simran 3

Help Ankita to complete the code.

import _____ as plt #Statement -1


students = ['Karan', 'Lina', 'Raj', 'Simran']
books_read = [12, 9, 5, 3]
plt.bar( students, _____, label='Books Read') #Statement -2
plt.xlabel('Student Name')
plt._____('Books Read') #Statement -3
plt.legend()
plt.title('_____') #Statement -4
plt.show()

Page 10 of 14
I. Write the suitable code for the import statement in the blank space in the
line marked as Statement -1.
II. Refer to the graph shown above and fill in the blank in Statement -2 with
suitable Python code .
III. Fill in the blank in Statement -3 with the name of the function to set the
label on the y-axis.
IV. Refer the graph shown above and fill the blank in Statement -4 with
suitable Chart Title.

34 (A)
(B) Rahul, who works as a database designer, has developed a database for a
bookshop. This database includes a table BOOK whose column (attribute)
names are mentioned below:

BCODE : Shows the unique code for each book.


TITLE : Indicates the book’s title.
AUTHOR : Specifies the author’s name.
PRICE : Lists the cost of the book.
Table: BOOK
BCODE TITLE AUTHOR
PRIC
E
B001 MIDNIGHT’S CHILDREN SALMAN RUSHDIE 500
B002 THE GOD OF SMALL
THINGS ARUNDHATI ROY 450
B003 A SUITABLE BOY VIKRAM SETH 600
B004 THE WHITE TIGER ARAVIND ADIGA 399
B005 TRAIN TO PAKISTAN KHUSHWANT
SINGH 350

I. Write SQL query to display book titles in lowercase.


II. Write SQL query to display the highest price among the books.
III. Write SQL query to display the number of characters in each
book title.
IV. Write SQL query to display the Book Code and Price sorted by
Price in descending order.
OR
Dr. Kavita has created a database for a hospital's pharmacy. The database
includes a table named MEDICINE whose column (attribute) names are
mentioned below:
MID: Shows the unique code for each medicine. 4
Page 11 of 14
MED_NAME : Specifies the medicine name
SUPP_CITY : Specifies the city where the supplier is located.
STOCK : Indicates the quantity of medicine available.
DEL_DATE : Specifies the date when the medicine was delivered.
Table: MEDICINE
MID MED_NAME SUPP_CITY STOCK DEL_DATE
M01 PARACETAMOL MUMBAI 200 2023 -06-15
M02 AMOXICILLIN KOLKATA 50 2023 -03-21
M03 COUGH SYRUP
BENGALURU 120 2023 -02-10
M04 INSULIN CHENNAI 135 2023 -01-25
M05 IBUPROFEN
AHMEDABAD 30 2023 -04-05
Write the output of the following SQL Queries.
I. Select LENGTH(MED_NAME) from MEDICINE where STOCK >
100;
II. Select MED_NAME from MEDICINE where month(DEL_DATE)
= 4;
III. Select MED_NAME from MEDICINE where STOCK between 120
and 200;
IV. Select max(DEL_DATE) from MEDICINE ;

36 Consider the DataFrame df shown below.


MovieID Title Year Rating

2 3 3 IDIOTS 2009 8.4

4 5 ANDHADHUN 2018 8.3

Write Python statements for the DataFrame df to:


I. Print the first two rows of the DataFrame df.
II. Display titles of all the movies.
III. Remove the column rating.
IV. Display the data of the 'Title ' column from indexes 2 to 4 (both
included)
V. Rename the column name 'Title' to 'Name' . 5

37 (A)

(B) Write suitable SQL query for the following:


I. To display the average score from the test _results column
(attribute) in the Exams table
II. To display the last three characters of the
registration _number column (attribute) in the Vehicles
table. (Note: The registration numbers are stored in the format
DL-01-AV-1234)
III. To display the data from the column (attribute) username in the
Users table, after eliminating any leading and trailing spaces.
IV. To display the maximum value in the salary column (attribute)
of the Employees table.
V. To determine the count of rows in the Suppliers table.
OR
Write suitable SQL query for the following:
I. Round the value of pi (3.14159) to two decimal places. 5
Page 14 of 14
II. Calculate the remainder when 125 is divided by 8.
III. Display the number of characters in the word 'NewDelhi'.
IV. Display the first 5 characters from the word 'Informatics
Practices'.
V. Display details from 'email' column (attribute), in the
'Students' table, after removing any leading and trailing
spaces.

You might also like