/**/ Python & MySQL: 2024

Thursday, September 12, 2024

CBSE SAMPLE QUESTION PAPER (INFORMATICS PRACTICES) 2024 - 25

SAMPLE QUESTION PAPER (THEORY)

CLASS - XII  SESSION: 2024-25

INFORMATICS PRACTICES (065)

Time allowed: 3 Hours                                                                                           M.M 70 

---------------------------------------------------------------------------------------

General Instructions:

Please check this questions paper contains 37 questions.

All questions are compulsory. However, internal choices have been provided in some questions. Attempt only one of the choices in such questions.

The paper is divided into 5 sections - A, B, C, D and E.

Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.

Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.

Section C consists of 4 questions (20 to 32). Each question carries 3 Marks.

Section D consists of 2 case study type questions (22 to 34). Each quesion carries 4 Marks.

Section E consists of 3 questions (35 to 37). Each question carries 5 Marks.

All programming questions are to be answered using Python Language  only.

In case of MCQ, text of the correct answer should also be written.

Section -A (21 x 1 = 21 Marks)

1. State whether the following statement is Treu or False:

Slicing can be used to extract a specific portion from a Pandas Series.

Ans: True

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

Ans: Filter rows based on a specific condition

3. Identify the networking device responsible for routing data packets based on their destination addresses.

(a) Modem

(b) Hub

(c) Repeater

(d) Router

Ans:Router

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

Ans: DROP TABLE

5. e-waste refers to:

(a) Software that has become obsolete

(b) Data that has been deleted from a storage device

(c) Viruses that infect computer

(d) Electronic devices that are no longer in use

Ans:Electronic devices that are no longer in use

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)

Ans:df['column_name']

7. By default, the plot( ) function of Matplotlib draws a _____ plot.

(a) histogram

(b) column

(c) bar

(d) line

Ans:line

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.

Ans: True

9. Which of the following Pthon stateemnts 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')

Ans: pd.read_csv('filename.csv')

10. What is plagiarism ?

(a) Using copyrighted material without giving proper acknowledgement to the source

(b) Downloading illegal software.

(c) Spreading misinformation online.

(d) Hacking into computer systems.

Ans:Using copyrighted material without giving proper acknowledgement to the source

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

Ans: Rows

12. In which of the network topologies do all devices connect to a central point, such as a switch or hub ?

(a) Star

(b) Bus

(c) Tree

(d) Mesh

Ans: Star

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

Ans: 5

14. Identify the type of cybercrime that involves sending fraudulent emails to deceive individuals into revealing sensitive information.

(a) Hacking

(b) Phishing

(c) Cyberbullying

(d) Cyberstalking

Ans: Phishing

15. While creating a Series using a dictionary, the keys of the dictionary become:

(a) Value of the Series

(b) Idices of the Series

(c) Data type of the Series

(d) Name of the Series

Ans: Idices 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

Ans:  P-2, Q-4, R-1, S-3

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

Ans: Filtering data based on condition

18. Which Matplotlib plot is best suited to represent changes in data over time?

(a) Bar plot

(b) Histogram

(c) Line plot

(d) Histogram & Bar plot

Ans: Line plot

19. Which tpe of network covers a small geographical area like a single office, building, or school campus ?

(a) PAN

(b) MAN

(c) LAN

(d) WAN

Ans: LAN

Q-20 and Q-21 are Assertion (A) and Reason (R) Type questions. Choose the correct option as:

(a) Both Assertion (A) and Reason (R) are true, and Reason (R) is the correct explanation of Assertion (A).

(b) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correction explation of Assertion (A)

(c) Assertion (A) is True, but Reason (R) is False

(d) Assertion (A) is False, but Reason (R) is True

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

Reason (R): DataFrames are size mutable.

Ans: Both Assertion (A) and Reason (R) are true, and Reason (R) is the correct explanation of Assertion (A).

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.

Ans: Assertion (A) is False, but Reason (R) is True

Section - B (7 x 2) = 14 Marks)

22 (A) What is a Series in Python Pandas? Also, give a suitable example to support your answer.

Ans: A Series is a one-dimensional array containing a sequence of values of any data type (int, float, list, string, etc) which by default have numeric data labels starting from zero. 

We can imagine a Pandas Series as a column in a spreadsheet. An example of a series containing the names of students is given below:

Index       Value 

0              Arnab 

1             Samridhi 

2             Ramit 

3             Divyam

OR

(B) What does the term 'library'  signify in Python ? Mention one use for each of the following libraries:

Pandas

Matplotlib

Ans: Library: A collection of modules providing functionalities for specific tasks. 

Pandas: Used for data analysis 

Matplotlib: Used for creating plots

23. What are intellectual property rights (IPR), and why are they important in the digital world ?

Ans: Intellectual Property Rights (IPR)

These are legal rights that protect the creations of the human intellect. The nature of these works can be artistic, literary or technical etc.

Importance in the digital world

These rights help prevent the unauthorized use or reproduction of digital content and ensure that creators are fairly compensated and incentivized for their original work.

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.

Ans: (I) SELECT SUBSTRING('Database Management System', 10, 6) ;

(II)  SELECT INSTR('Database Management System', 'base') ;

25. (A) What is Internet and how does it differ from World Wide Web (WWW) ?

Ans: The Internet is a vast network of interconnected computer networks facilitating global communication and data exchange. The World Wide Web (WWW), on the other hand, is a system of interlinked hypertext documents accessed via the Internet.

OR

(B) Explain the concept of browser cookies and menttion one advantage of using them.

Ans: Browser cookies: Small pieces of data stored on our digital devices by websites to remember information and personalize our experience.

Advantage: Improve user experience by remembering preferences, like our preferred language and other settings.

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

Ans:  Primary Key : A set of attributes that can uniquely identify each row in a table (relation). It must contain unique values and cannot be null.

How it differs from Candidate Key

There can be multiple Candidate Keys in a table (relation), but only one of them is selected as Primary Key.

27. Mention two helth concerns associated with excessive use of Digital Devices.

Ans: Two health concerns due to excessive use of Digital Devices:

a) Eye strain and vision problems.

b) Musculoskeletal issues like neck and back pain.

28 (A) 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)

Ans:

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

28  (B)  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(_______)

Ans:

                    Section - C (4 x 3 = 12 Marks)

29. Ayesha's family is replacing their old computer with a new one. They decide to throw the old computer in a nearby empty field/plot.

I. Explain any one potential environmental hazard associated with improper e-waste disposal.

II. Suggest one responsible way to Ayesha's family for proper disposal of their old computer.

III. Describe the importance of recycling in e-waste management.

Ans:

30 (A) Write a Python program to create the following DataFrame using a list of dictionaries.

Ans: 

OR

(B) Write a Python Program to create a Pandas Series as shown below using a dictionary. Note that the left column indicates the indices and the right column displays the data.


Ans:

31. (1)   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 Students Table

              1, Supriya, Singh, 2010-08-18, 75.5

Ans:

32. (A) Consider the following tables:

Table 1:

EMPLOYEE which stores Employee ID (EMP_ID), Employee Name (EMP_NAME), Employee City (EMP_CITY)

Table 2:

PAYROLL which stores Employee ID (EMP_ID), Department (DEPARTMENT), Designation (DESIGNATION), and Salary (SALARY) for various employees.

Note: Attribute names are written within brackets.

Table: EMPLOYEE

Table: PAYROLL

Write appropriate SQL queries for the following:

I. Display department-wise average Salary.

II. List all designations in the decreasing order of Salary.

III. Display employee name along with their corresponding departments.

Ans:

OR

32 (B) Consider the following tables:

Table 1:

ATHLETE, which stores AthleteID, Name, Country. The table displays basic information of the athletes

Table 2:

MEDALS, which stores AthleteID, Sport, and Medals. The table displays the number of medals won by each athlete in their respective sports.

Table: ATHLETE


Table: MEDALS


Write appropriate SQL queries for the following:

I. Display the sports-wise total number of medals won.

II. Display the names of all the Indian athletes in uppercase.

III. Display the athlete name along with their corresponding sports

Ans:

Section-D (2 x 4 = 8 Marks)

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.

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()

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.

Ans:

34. (A) 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.


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

34 (B) 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.

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

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;

Section-E (3 x 5 = 15 Marks)

35. ABC Pvt. Ltd., a multinational technology company, is looking to establish its Indian Head Office in Bengaluru, and a regional office branch in Lucknow. The Bengaluru head office will be organized into four departments: HR, FINANCE, TECHNICAL, AND SUPPORT. As a network engineer, you have to propose solutions for various queries listed from I to V.


The shortest distances between the departments/offices are as follows:


The number of computers in each department/office is as follows:


I. Suggest the most suitable department in the Bengaluru Office Setup, to install the server. Also, give a reason to justify your suggested location.

II. Draw a suitable cable layout of wired network connectivity between the departments in the Bengaluru Office.

III. Which networking device would you suggest the company to purchase to interconnect all the computers within a department in Bengaluru Office?

IV. The company is considering establishing a network connection between its Bengaluru Head Office and Lucknow regional office. Which type of network—LAN, MAN, or WAN—will be created? Justify your answer.

V. The company plans to develop an interactive website that will enable its employees to monitor their performance after login. Would you recommend a static or dynamic website, and why?

Ans: 

36. Consider the DataFrame df shown below


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'.

Ans:

37. (A)  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.

Ans:

OR

37 (B)  Write suitable SQL query for the following:

I. Round the value of pi (3.14159) to two decimal places.

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.

Ans: 












Tuesday, September 3, 2024

Unit Test - IP (Class 12) 2024-25

 Unit Test - Class - XII

Subject - Informatics Practices (IP - 065)       

                                                                         MM: 20

============================

1. Pyplot is an interface of Python’s _________ library.

  1. Seaborn
  2. Plotly
  3. Ggplot
  4. Matplotlib

2. Which of the following is not a valid chart type?

  1. Histogram
  2. Statistical
  3. Pie
  4. Bar

3. The command used to give a heading to a graph is ________

  1. plt.show()
  2. plt.plot()
  3. plt.xlabel()
  4. plt.title()

4. Which function would you use to set the limits for x-axis of the plot?

  1. limits()
  2. xlimits()
  3. xlim()
  4. lim()

5. Which function is used to show legends?

  1. display()
  2. show()
  3. legend()
  4. legends()

6. Write a program to plot a line chart to depict the changing weekly onion prices for four weeks. Give appropriate axes labels.

Solution:

import matplotlib.pyplot as plt

week = [1,2,3,4]

prices = [40, 80, 100, 50]

plt.plot(week, prices)

plt.xlabel('week')

plt.ylabel('Onion prices')

plt.show()

7. Create an array, A, in the range 1 to 20 with values 1.25 apart. Another array B, contains the log values of the elements in the array A.

Write a program to create a scatter plot of first vs. second array (array A vs. B) with red circle marker ; specify the x-axis (containing first array’s values) title as ‘Random Values’ and y-axis title as ‘Logarithm Values’.

Solution:

import matplotlib.pyplot as plt

import numpy as np

a = np.arange(1, 20, 1.25)

b = np.log(a)

plt.plot(a, b, 'ro')

plt.xlabel('random Values')

plt.ylabel('Logarithm values')

plt.show()

8. Write a program to plot a bar chart from the medals won by India. make sure that Gold, Silver, Bronze and Total tally is represented through different colours.

Solution:

import matplotlib.pyplot as plt

info = ['Gold', 'Silver', 'Bronze', 'Total']

India = [30, 20, 20, 70]

plt.bar(info, India, color =['gold', 'silver', 'brown', 'black'])

plt.xlabel("Medal Type")

plt.ylabel('Medal Count')

plt.show()

9. Prof. Awasthi is doing some research in the field of Environment. For some plotting purpose, he has generated some data as:

mu = 100

sigma = 15

x = mu + sigma * numpy.random.randn(10000)

Write a program to plot this data on a horizontal histogram with this data. 

Solution:

import matplotlib.pyplot as plt

import numpy as np

mu = 100

sigma = 15

x = mu+sigma*np.random.randn(10000)

plt.hist(x, bins = 30, orientation = 'horizontal')

plt.title('Research data Histogram')

plt.show()

==============================

MCQ Answer: 1. Matplotlib,   2. Statistical      3. plt.title( )

                        4. xlim( )       5. legend( )

===============================


Friday, August 30, 2024

Objective Type Questions (Class 12) 2024-25

Objective Type Questions 

Session : (2024-25)

Class - XII

1.      Python Pandas was developed in ______.

a.      2008

b.      2009

c.       2010

d.      2012

2.      head() is used to return first ______ rows.

a.      n-1

b.      n+1

c.       n2

d.      n

3.      Which function is used to sort the series values using values?

a.      sort()

b.      values()

c.       sort_values()

d.      values_sort()

4.      The columns of DataFrame cab be

a.      Heterogeneous

b.      Homogeneous

c.       Both a and b

d.      None of these

5.      loc takes two single operators separated by____

a.      dot(.)

b.      semicolon(;)

c.       colon(:)

d.      comma(,)

6.      Which function is used to delete a row from DataFrame?

a.      del()

b.      drop()

c.       delete()

d.      dropcol()

7.      In Boolean indexing ______ can be used to filter the data.

a.      boolean vectors

b.      Boolean column

c.       Boolean mapper

d.      Boolean label

8.      The full form of CSV is

a.      Comma Separate Value

b.      Comma Separated Values

c.       Common Separated Values

d.      None of the above

9.      Which of the following is/are library function(s) used to load data from CSV file into

a.      read_csv()

b.      to_csv()

c.       both a and b

d.      None of these

10.  The name “Pandas” is derived from the term

a.      Panel Data

b.      Panel Series

c.       Python Document

d.      Panel Data Frame

11.  Method or function to add a new row in a dataframe is

a.      .loc()

b.      .iloc()

c.       join()

d.      add()

12.  Which of the following import statement is not correct?

a.      import pandas as class12

b.      import pandas as 1pd

c.       import pandas as pd1

d.      import pandas as pd

13.  While accessing the column from the dataframe, we can specify the column name. In case column does not exist, which type of error it will raise?

a.      Key Error

b.      Syntax Error

c.       Name Error

d.      Runtime Error

14.  Function to display the first n rows in the DataFrame is

a.      tail(n)

b.      head(n)

c.       top(n)

d.      first(n)

15.  Which function will be used to read data from a CSV file into Pandas dataframe?

a.      readcsv()

b.      to_csv()

c.       read_csv()

d.      csv_read

16.  Which of the following is not an attribute of Pandas dataframe?

a.      length

b.      T

c.       size

d.      shape

17.  What will be the output of the given code?

import pandas as pd

s = pd.Series([1, 2, 3, 4, 5], index = [‘akram’, ‘brijesh’, ‘charu’, ‘deepika’, ‘era’])

print(s[‘charu’])

 

a.      1

b.      2

c.       3

d.      4

18.  What is a correct syntax to return the values of first tow of a Pandas DataFrame? Assuming the name of the DataFrame is dfRent.

a.      dfRent[0]

b.      dfRent.loc[1]

c.       dfRent.loc[0]

d.      dfRent.iloc[0]

19.  Write the output of the given code.

import pandas as pd

S1 = pd.Series([5, 6, 7, 8, 10], index = [‘v’, ‘w’, ‘x’, ‘y’, ‘z’])

p =[2, 6, 1, 4, 6]

S2 = pd.Series(p, index = [‘z’, ‘y’, ‘a’, ‘w’, ‘v’])

Print(S1-S2)

20.  Which command will be used to delete 3 and 5 rows of the dataframe. Assuming the dataframe name as DF.

a.      DF.drop([2, 4], axis = 0)

b.      Df.drop([2, 4], axis = 1)

c.       DF.drop([3, 5], axis = 1)

d.      Df.drop([3, 5])

Answers:

1. 2008    2. n    3. sort_values()    4. Heterogeneous    5. comma(,)

6. drop()       7. boolean vectors    8. Comma Separated Values    

9. Both (a) and (b)        10. Panel Data        11. .loc()    

12. import pandas as 1pd        13. Key Error        14. head(n)

15. read_csv()        16. length        17. 3        18. dfRent.loc[0]

19.                                20. DF.drop([2, 4], axis = 0)







CLASS XI HALF YEARLY QP WTH MS 2024

  Half Yearly Examination: 2024-25 Informatics Practices (065) Class- XI       Time Allowed: 3hrs                                     ...