0% found this document useful (0 votes)
7 views17 pages

12 Ip Set B Anskey

The document is an answer key for the Pre-Board Examination in Informatics Practices for Class XII at Vidya Jain Public School, detailing questions and answers across various sections. It includes multiple-choice questions, SQL queries, Python code explanations, and distinctions between SQL clauses. The document serves as a comprehensive guide for students to review their understanding of the subject matter.

Uploaded by

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

12 Ip Set B Anskey

The document is an answer key for the Pre-Board Examination in Informatics Practices for Class XII at Vidya Jain Public School, detailing questions and answers across various sections. It includes multiple-choice questions, SQL queries, Python code explanations, and distinctions between SQL clauses. The document serves as a comprehensive guide for students to review their understanding of the subject matter.

Uploaded by

msindiatravel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

SET- A

VIDYA JAIN PUBLIC SCHOOL, ROHINI, NEW DELHI


PRE-BOARD EXAMINATION - 1 (2024-25)
SUBJECT –INFORMATICS PRACTICES (065)
ANSWER KEY
CLASS –XII
Duration : 3 Hours M.M.:70
Q. Details of the questions Mark(s)
SECTION-A
Q.1 c. Shred sensitive documents, use strong passwords, and monitor financial accounts 1
Q.2 b. Air Pollution 1
Q.3 c. Router 1
Q.4 d. COUNT() 1
Q.5 a. plt.hist(values) 1
Q.6 d. SELECT * FROM customers WHERE email IS NULL; 1
Q.7 c. Bus topology 1
Q.8 b. Real estate properties 1
Q.9 c. Phishing 1
Q.10 c. A is True but R is False 1
Q.11 b. Both A and R are true but R is not the correct explanation 1
Q.12 b. GROUP BY, ORDER BY 1
Q.13 c. head() 1
Q.14 a. UCASE() 1
Q.15 d. numeric 1
Q.16 d. NOW() 1
Q.17 a. 15.79 1
Q.18 d. Linux 1
SECTION-B
Q.19 Here are four important net etiquette (netiquette) or communication etiquette principles 2
that Rashi should follow to become a good netizen while using the internet:

1. **Be Respectful and Polite:**


- Treat others online as you would in person. Use polite language, avoid using all caps
(as it can be perceived as shouting), and refrain from posting hurtful or offensive
comments. Respect differing opinions and engage in constructive discussions.

2. **Think Before You Post:**


- Carefully consider the content of your messages before posting. Whether it’s a
comment on social media or an email, ensure that what you write is clear, respectful, and
free of unnecessary negativity. Once something is posted online, it can be difficult to
remove or retract.

3. **Protect Personal Information:**


- Avoid sharing sensitive personal information (like your home address, phone number,
or financial details) in public forums or social media. Be mindful of your privacy and the
privacy of
Q.20 Here are the correct answers to your SQL query questions: 2

i. **To retrieve the length of the given string "CBSE BOARD SQP @ 2023!", which
SQL function should you use?**
- **c. LENGTH()**

The `LENGTH()` function in SQL is used to return the length of a string.

ii. **To find out if ‘@’ symbol is present in the values of the email id column or not,
which function out of the following should be used?**
- **b. Instr()**

The `INSTR()` function is typically used to find the position of a substring within a
string, which can help determine the presence of the '@' symbol in an email address.

Therefore, the answers are **i. c. LENGTH()** and **ii. b. Instr()**.


Q.21 **URL** stands for **Uniform Resource Locator**. It is the address used to access 2
resources on the internet. A URL specifies the location of a resource as well as the
protocol used to retrieve it. URLs are fundamental to the operation of the World Wide
Web, enabling browsers to locate web pages, images, videos, and other types of
resources.

A typical URL consists of several components:


1. **Protocol**: This indicates the method used to access the resource (e.g., `http`,
`https`, `ftp`).
2. **Domain Name**: This is the name of the website (e.g., `example.com`).
3. **Path**: This specifies the specific resource on the server (e.g., `/folder/page.html`).
4. **Query Parameters** (optional): These are additional parameters for accessing
specific content (e.g., `?id=123&sort=asc`).

**Example of a URL:**
```
https://www.wikipedia.org/wiki/URL
```

In this example:
- **Protocol**: `https`
- **Domain Name**: `www.wikipedia.org`
- **Path**: `/wiki/URL` (indicating a specific page on Wikipedia about URLs).
Q.22 Let's analyze the provided code step by step. 2

```python
import pandas as pd

lst1 = [20, 35, 40]


ser1 = pd.Series([20, 35, 40])

print(lst1 + lst1)
print(ser1 + ser1)
```

1. **`print(lst1 + lst1)`**:
- Here, `lst1` is a regular Python list. When you use the `+` operator with lists, it
concatenates the lists instead of performing element-wise addition.
- Therefore, `lst1 + lst1` will result in:
```
[20, 35, 40, 20, 35, 40]
```
2. **`print(ser1 + ser1)`**:
- `ser1` is a Pandas Series. When you use the `+` operator with Series, it performs
element-wise addition.
- In this case, each corresponding element of `ser1` will be added together, resulting in:
```
0 40
1 70
2 80
dtype: int64
```

So, the output of the code will be:


```
[20, 35, 40, 20, 35, 40]
0 40
1 70
2 80
dtype: int64
```

This shows the concatenated list from the first print statement and the resulting Series
from the second.
Q.23 In Python, you can generate quartiles using several functions, but the most commonly 2
used methods are from the **NumPy** library and the **Pandas** library. Here are the
ways to calculate quartiles using both libraries:

### Using NumPy:


You can use the `numpy.percentile()` function to compute quartiles. For example, to get
the first, second (median), and third quartiles:

```python
import numpy as np

data = [1, 2, 3, 4, 5, 6, 7, 8, 9]
Q1 = np.percentile(data, 25) # First quartile (25th percentile)
Q2 = np.percentile(data, 50) # Second quartile (median, 50th percentile)
Q3 = np.percentile(data, 75) # Third quartile (75th percentile)

print(Q1, Q2, Q3)


```

### Using Pandas:


You can also use the `quantile()` method of a Pandas Series or DataFrame to get
quartiles:

```python
import pandas as pd

data = pd.Series([1, 2, 3, 4, 5, 6, 7, 8, 9])


Q1 = data.quantile(0.25) # First quartile
Q2 = data.quantile(0.50) # Second quartile (median)
Q3 = data.quantile(0.75) # Third quartile

print(Q1, Q2, Q3)


```
Both approaches will give you the quartiles of the dataset. Use the method that best fits
your needs based on whether you're working with raw data (NumPy) or in a DataFrame
format (Pandas).
Q.24 In SQL, both the **HAVING** clause and the **WHERE** clause are used to filter 2
records, but they serve different purposes and are used in different contexts. Here’s a
clear distinction between the two:

### WHERE Clause

- **Purpose**: The WHERE clause is used to filter records before any groupings are
made. It is applied to individual rows in the table.
- **Usage**: You use WHERE when you want to filter data based on specific conditions
on the fields in the input tables.
- **Scope**: It can refer to any column in the table.
- **Example**:
```sql
SELECT *
FROM employees
WHERE department = 'Sales';
```
In this example, only the records of employees who work in the Sales department are
retrieved.

### HAVING Clause

- **Purpose**: The HAVING clause is used to filter records after aggregation. It is


applied to groups of records created by the GROUP BY clause.
- **Usage**: You use HAVING when you want to filter data based on the results of
aggregate functions (like SUM, COUNT, AVG, etc.).
- **Scope**: It can refer to aggregate functions as well as columns specified in the
GROUP BY clause.
- **Example**:
```sql
SELECT department, COUNT(*) AS num_employees
FROM employees
GROUP BY department
HAVING COUNT(*) > 10;
```
In this example, the query retrieves departments that have more than 10 employees by
first grouping the employees by department and then applying the HAVING clause on
the aggregated result.

### Key Distinctions

1. **Point of Execution**:
- **WHERE** filters records before aggregation takes place.
- **HAVING** filters records after aggregation.

2. **Aggregate Functions**:
- **WHERE** cannot be used with aggregate functions. If you try to use an aggregate
function in WHERE, it will result in an error.
- **HAVING** allows filtering based on aggregate functions.

3. **Usage Context**:
- **WHERE** is used with SELECT, UPDATE, and DELETE statements.
- **HAVING** is typically used with SELECT statements that include GROUP BY.
### Summary

- Use **WHERE** to filter individual rows based on specified conditions.


- Use **HAVING** to filter groups of records after aggregation is performed.

Understanding the difference between these two clauses is critical for writing effective
SQL queries and for manipulating data as needed.
Q.25 Let's analyze the given code step by step to determine the output. 2

### Code Explanation


1. **Import Pandas**: The code starts by importing the pandas library.
2. **Data Definition**: It creates a list of dictionaries, `data`, where each dictionary can
represent a row in the DataFrame. Each dictionary can have different keys.
```
data = [{'a': 1, 'b': 2}, {'a': 5, 'b': 10, 'c': 20}]
```
- The first dictionary has keys 'a' and 'b'.
- The second dictionary has keys 'a', 'b', and 'c'.

3. **Creating DataFrame df1**:


```python
df1 = pd.DataFrame(data, index=['first', 'second'], columns=['a', 'b'])
```
- The DataFrame `df1` is created with specified index labels ('first' and 'second') and
requested columns ('a' and 'b').
- Since both 'a' and 'b' exist in the dictionaries, `df1` will look like this:
```
a b
first 1 2
second 5 10
```
- Note: The missing values for 'b' in the second dictionary will be filled with NaN (Not
a Number).

4. **Creating DataFrame df2**:


```python
df2 = pd.DataFrame(data, index=['first', 'second'], columns=['a', 'b1'])
```
- The DataFrame `df2` is created, but this time it requests a column 'b1', which does not
exist in the dictionaries.
- Since 'b1' does not exist, `df2` will result in NaN for that column:
```
a b1
first 1 NaN
second 5 NaN
```

### Print Outputs


Now, let's print the data frames to see their structure as per the defined logic.

### Final Output of the Code

Based on the explanations above, the output will be as follows:

```plaintext
a b
first 1 2
second 5 10
```

```plaintext
a b1
first 1 NaN
second 5 NaN
```

So `df1` has filled values, and `df2` shows NaN for the column 'b1', which was not
present in the original data.
SECTION-C
Q.26 To complete the given Python code and achieve the required output of "California," we 3
will need to correctly fill in the blanks. Here's how the completed code would look:

```python
import pandas as pd

data = {'Yosemite': 'California', 'Yellowstone': 'Wyoming', 'Glacier': 'Montana', 'Rocky


Mountain': 'Colorado'}
national_parks = pd.Series(data) # Fill in the data as a Series
print(national_parks['Yosemite']) # Access California using the key 'Yosemite'
```

### Explanation of the Completed Code:


1. **Import Statement**: `import pandas as pd` imports the pandas library.
2. **Data Definition**: `data` is a dictionary mapping national park names to their
corresponding states.
3. **Creating the Series**: `national_parks = pd.Series(data)` creates a pandas Series
from the dictionary.
4. **Output the value for 'Yosemite'**: `print(national_parks['Yosemite'])` prints the
value associated with the key 'Yosemite', which is 'California'.

### Output
When you run this code, the output will be:
```
California
```

### Final Completed Code


Here’s the final version with the necessary parts filled in:

```python
import pandas as pd
data = {'Yosemite': 'California', 'Yellowstone': 'Wyoming', 'Glacier': 'Montana', 'Rocky
Mountain': 'Colorado'}
national_parks = pd.Series(data)
print(national_parks['Yosemite'])
```
Q.27 To perform the tasks as specified, you will need to execute SQL statements that alter the 3
existing table named "Nutrients" in the "FOOD" database. Below are the SQL statements to
accomplish both tasks:

### i. Add a new column named “Plan_Start_Date” (Date) to the "Nutrients" table
To add a new column to an existing table, you can use the `ALTER TABLE` statement along with
`ADD COLUMN`:

```sql
ALTER TABLE Nutrients
ADD Plan_Start_Date DATE;
```

### ii. Modify the "Calorie" column to change its data type to Float

To modify an existing column's data type, you can again use the `ALTER TABLE` statement, this
time with `MODIFY` (or `ALTER COLUMN`, depending on the SQL dialect you are using):

For SQL Server:

```sql
ALTER TABLE Nutrients
ALTER COLUMN Calorie FLOAT;
```

For MySQL:

```sql
ALTER TABLE Nutrients
MODIFY Calorie FLOAT;
```

For PostgreSQL:

```sql
ALTER TABLE Nutrients
ALTER COLUMN Calorie TYPE FLOAT;
```

### Summary of SQL Statements

Here's a complete summary of the SQL commands you would run:

```sql
-- Add a new column Plan_Start_Date of type DATE
ALTER TABLE Nutrients
ADD Plan_Start_Date DATE;

-- Modify the Calorie column to change its data type to FLOAT


ALTER TABLE Nutrients
ALTER COLUMN Calorie FLOAT; -- SQL Server
-- OR
MODIFY Calorie FLOAT; -- MySQL
-- OR
ALTER COLUMN Calorie TYPE FLOAT; -- PostgreSQL
```

i. Make sure to use the appropriate command for the SQL database you are using.
Q.28 Sure! Let's break down the concepts of active and passive digital footprints, using Alex's 3
online activities as a framework.

### a. Active Digital Footprint


**Concept**: An active digital footprint refers to the data that individuals intentionally
create about themselves when they actively participate in online activities. This includes
any information that users share or upload consciously.

**Examples from Alex's Online Activities**:


- **Social Media Posts**: Each time Alex posts an update, shares photos, or comments
on his friends' posts on platforms like Facebook, Instagram, or Twitter, he is creating an
active digital footprint. For instance, if Alex shares a photo of a recent vacation, that
photo and the associated metadata (like location and time) become part of his digital
presence.

- **Blogging or Sharing Articles**: If Alex writes blog posts or shares articles he finds
interesting, he is actively contributing content to the internet, which becomes part of his
digital footprint.

- **Online Shopping**: When Alex makes purchases or reviews products on e-


commerce sites, the details of his orders, shopping preferences, and feedback are
recorded as part of his digital activities.

### b. Passive Digital Footprint

**Concept**: A passive digital footprint, on the other hand, refers to the data that is
collected about an individual without their direct input. This includes data generated by
tracking technologies and analytics tools, which monitor user behavior and interactions.

**Examples of How It Is Generated in Alex's Online Interactions**:


- **Cookies and Tracking**: When Alex visits websites, cookies are stored on his
device, tracking his browsing habits. For instance, if he searches for running shoes
online, websites can track his visits and later show him targeted ads based on his
interests.

- **Metadata from Social Media and Apps**: Even if Alex does not share his location
intentionally, social media platforms and mobile apps can collect metadata (such as
device type, IP address, and usage patterns) about him. For example, if Alex often uses a
fitness app, it can log his path and exercise routines, contributing to his digital profile
without his direct action.

- **Third-party Services**: If Alex logs into various sites using his social media
accounts (like signing into a shopping site using his Facebook login), it generates passive
footprints that provide third parties with data about his online behavior across multiple
platforms.

### c. Implications for Alex's Online Privacy and Security

1. **Increased Exposure to Data Breaches**: Both active and passive footprints


contribute to the amount of data stored online. If any platform Alex uses experiences a
data breach, his personal information could be exposed, leading to risks such as identity
theft or account hacks.

2. **Targeted Advertising**: The passive digital footprint can lead to highly


personalized advertising based on Alex’s browsing habits and preferences. While some
may find this convenient, it raises concerns about privacy, as Alex might not be
comfortable with the extent to which companies track him for marketing purposes.

3. **Reputation Management**: Active digital footprints can impact Alex’s reputation.


Posts, comments, or photos shared on social media may have lasting visibility, affecting
his personal and professional life. Employers or friends might form opinions based on
what they find about him online.

4. **Surveillance and Data Collection**: Both types of footprints contribute to a larger


ecosystem of surveillance where companies and sometimes government entities track
user behavior. This may lead to feelings of being monitored, impacting Alex's freedom to
express himself online.

5. **Difficulty in Deleting Information**: Over time, the accumulated data (both active
and passive) can make it difficult for Alex to manage his online presence. Even if he
deletes posts or accounts, traces may remain, and companies may retain records of his
interactions.

### Conclusion

For Alex, understanding the implications of his active and passive digital footprints is
vital for managing his online privacy and security. Proactively managing what he shares,
being aware of how his online activities are tracked, and using privacy settings can help
mitigate some of the risks associated with his digital identity.
Q.29 In MySQL, the `UPDATE` and `ALTER` commands serve two distinct purposes and are 3
used in different contexts. Here are the differences between the two:

### 1. Purpose

- **UPDATE Command**:
- The `UPDATE` statement is used to modify existing records (rows) in a table. It
allows you to change the values of one or more columns for one or more records based
on specified conditions.

- **ALTER Command**:
- The `ALTER` statement is used to modify the structure of a database object, such as a
table. It can be used to add, modify, or delete columns or constraints, as well as to rename
a table.

### 2. Functionality

- **UPDATE**:
- Changes data in existing rows.
- You specify which records to change using a `WHERE` clause (although if you omit
this clause, all records in the table will be updated).
- Example:
```sql
UPDATE Employees
SET Salary = 60000
WHERE EmployeeID = 123;
```

- **ALTER**:
- Changes the schema of a table.
- Common operations include adding a new column, changing a column's data type,
renaming columns, or dropping columns.
- Example to add a column:
```sql
ALTER TABLE Employees
ADD COLUMN DateOfBirth DATE;
```

### 3. Data vs. Structure

- **UPDATE**:
- Affects the data contained in the rows of a table.
- Does not alter the structure of the table itself.

- **ALTER**:
- Affects the structure of the table (or the object being modified).
- Does not manipulate the actual data within the rows.

### 4. Usage Syntax

- **UPDATE Syntax**:
```sql
UPDATE table_name
SET column1 = value1, column2 = value2, ...
[WHERE condition];
```

- **ALTER Syntax**:
```sql
ALTER TABLE table_name
{ADD | DROP | MODIFY | CHANGE | RENAME} [COLUMN] column_name
datatype;
```

### 5. Transaction Support

- **UPDATE**:
- Can be included in transactions. This means you can commit or rollback updates based
on the success or failure of the transaction.

- **ALTER**:
- While certain `ALTER TABLE` commands can be part of transactions in some
situations, not all operations are transactional in nature. Some changes may take effect
immediately and cannot be rolled back.

### Conclusion

In summary, the `UPDATE` command is used to modify existing data within a table,
while the `ALTER` command is used to change the structure of the table itself.
Understanding these differences is essential for proper database management in MySQL.
Q.30 **Plagiarism** is the act of using someone else's work, ideas, expressions, or intellectual 3
property without proper attribution, presenting them as one's own. This unethical practice
can occur in various forms, including:

1. **Direct Plagiarism**: Copying text word-for-word without quotation marks or


citation.
2. **Self-Plagiarism**: Reusing one's own previously published work without proper
acknowledgment.
3. **Mosaic Plagiarism**: Interspersing copied phrases or ideas within one’s own
writing without proper citations.
4. **Accidental Plagiarism**: Failing to cite sources correctly or misquoting them
unintentionally.
### Example of Plagiarism

Let's say a student is writing a research paper on climate change. They come across a
well-articulated paragraph on the effects of global warming from a reputable article:

*"The effects of global warming are far-reaching, impacting ecosystems, weather


patterns, and sea levels. As temperatures rise, polar ice caps melt, leading to rising sea
levels that threaten coastal communities."*

If the student copies this paragraph into their paper without proper citation, it would be
considered direct plagiarism. The appropriate way to incorporate that information would
be to either quote it with quotation marks and a citation or paraphrase it, ensuring the
original author is credited.

### Proper Attribution

**Incorrect (Plagiarism)**:
In recent studies, it was found that the effects of global warming are far-reaching,
impacting ecosystems, weather patterns, and sea levels. As temperatures rise, polar ice
caps melt, leading to rising sea levels that threaten coastal communities.

**Correct (With Attribution)**:


According to a recent article, "The effects of global warming are far-reaching, impacting
ecosystems, weather patterns, and sea levels. As temperatures rise, polar ice caps melt,
leading to rising sea levels that threaten coastal communities" (Author, Year).

**Paraphrase Example**:
Rising global temperatures have significant consequences for the environment, including
alterations in ecosystems and increased sea levels due to melting polar ice, which poses a
risk to coastal areas (Author, Year).

### Conclusion

Plagiarism undermines academic integrity and can have serious consequences, including
loss of credibility, legal repercussions, and academic penalties. It is essential to attribute
sources correctly, whether through direct quotes, paraphrasing, or summaries, to give
credit to original authors and uphold ethical standards.
SECTION-D
Q.31 Imagine you are assigned a task to manage the inventory of an online store. The store 4
uses an SQL database to track product information in a table named 'Products.' The
'Products' table has columns for 'ProductID' (Primary Key), ‘ProductName', ‘Category’,
'QuantityInStock,' and 'PricePerUnit.' The following scenarios represent different
inventory management tasks:
i) Restocking: Due to a recent sale, the 'QuantityInStock' of a product with 'ProductID'
101, named "Laptop," needs to be increased by 10 units.
ii) Product Availability Check: You need to check the availability of a product named
"Wireless Mouse" in the 'Electronics' category.
iii)Product Update: The price of all products in the 'Electronics' category should be
increased by 5% to account for market changes. iv) Out of Stock: Identify and list the
products that are currently out of stock (QuantityInStock is 0). For each scenario,
provide the SQL statements to perform the necessary action.
Q.32 ### Phishing 4

**Phishing** is a form of cybercrime that involves tricking individuals into providing


sensitive information, such as usernames, passwords, credit card numbers, and other
confidential data. This is typically done through deceptive emails, messages, or websites
that appear to be from a legitimate source. Phishing attacks often exploit a sense of
urgency or curiosity in their targets to lure them into taking action.

#### Example of Phishing

Imagine you receive an email that looks like it is from your bank. The email states:

---

**Subject:** Urgent: Your Account is Locked!

Dear Customer,

We noticed unusual activity in your account, and for your protection, we have
temporarily locked it. Please click the link below to verify your identity and unlock your
account.

[Click Here to Verify Your Account]

Thank you for your prompt attention to this matter.

Sincerely,
Your Bank's Customer Service Team

---

If you click on the link, you may be redirected to a fraudulent website that looks
identical to your bank's official site. When you enter your login credentials, those details
are captured by the attacker, who can then access your bank account and potentially
steal your money.

To avoid phishing attacks, it’s crucial to:

- Verify the sender's email address and ensure it's legitimate.


- Look for spelling and grammatical errors, which often indicate a scam.
- Hover over links to check the actual URL before clicking.
- Use multifactor authentication when available.

### Computer Forensics

**Computer Forensics** is a branch of digital forensic science that involves the


recovery, analysis, and presentation of data from computer systems, networks, and
storage devices in a manner suitable for legal proceedings. The goal is to identify,
preserve, analyze, and present data that can be used in investigations, particularly in
privacy breaches, cybercrimes, and corporate espionage.

#### Example of Computer Forensics

Suppose a company experiences a data breach, where sensitive corporate data has been
stolen. The organization hires a computer forensic expert to investigate the incident.
The forensic process may involve the following steps:
1. **Preparation**: Ensure that forensic tools and equipment are ready for the analysis.
Acquire the necessary permissions to access the affected machines.

2. **Identification**: The investigator identifies compromised machines or servers. This


often includes checking logs, alerts from security systems, or reports from employees.

3. **Preservation**: They create an image (a complete copy) of the affected hard


drives, preserving the original data and ensuring it is not altered during the
investigation.

4. **Analysis**: Using forensic tools, the investigator analyzes the copied data to
uncover signs of unauthorized access, malware presence, or data exfiltration. They may
review file access logs, recover deleted files, and analyze network traffic.

5. **Reporting**: Finally, the investigator compiles a detailed report of their findings,


including evidence of the breach, how it occurred, and recommendations for preventing
future incidents. This report can be used in legal proceedings or for internal policy
changes.

### Conclusion

Phishing and computer forensics represent two important aspects of the digital
landscape. Phishing highlights the challenges faced by individuals and organizations in
maintaining cybersecurity, while computer forensics provides critical techniques for
investigating and responding to cybercrimes. Understanding both can significantly
enhance the ability to protect sensitive information and respond effectively to security
incidents.
SECTION-E
Q.33 Online campaigning has become an essential tool for businesses, organizations, and 5
political entities looking to reach their target audiences effectively. Here are five
advantages of online campaigning:

1. **Wider Reach and Accessibility**:


Online campaigning can reach a global audience, transcending geographical
limitations. This accessibility allows organizations to engage with diverse demographics,
making it easier to connect with potential supporters, customers, or voters anywhere in
the world.

2. **Cost-Effective**:
Compared to traditional campaigning methods (like print, television, or radio
advertisements), online campaigns can be much more cost-effective. Digital platforms
offer various budget options, allowing organizations of all sizes to create and promote
their messages without needing significant financial resources.

3. **Real-Time Engagement and Feedback**:


Online campaigns facilitate immediate interaction with audiences through social
media, emails, and dedicated campaign websites. Organizations can receive real-time
feedback, allowing them to adjust their strategies swiftly based on audience reactions,
questions, and comments.

4. **Targeted Marketing Capabilities**:


Online campaigning allows for precise targeting of specific audience segments using
demographic data, interests, and online behaviors. This capability helps organizations
tailor their messages to resonate with particular groups, increasing the likelihood of
engagement and conversion.

5. **Trackable Results and Analytics**:


Digital campaigns provide robust analytics tools that help organizations track
performance in real-time. Metrics such as click-through rates, engagement levels, and
conversion rates allow for a deeper understanding of campaign effectiveness, enabling
data-driven decision-making for future initiatives.

### Conclusion

Overall, online campaigning offers unique opportunities to engage audiences effectively


and efficiently, making it an indispensable tool in contemporary communication and
marketing strategies.
Q.34 You can achieve the tasks you've outlined using the Pandas library in Python. Below are 5
the code statements for each of your requests:

```python
import pandas as pd

# Creating the DataFrame


data = {
'Item': ['Capsicum', 'Capsicum', 'Chilli', 'Chilli', 'Lime'],
'Color': ['Red', 'Green', 'Red', 'Green', 'Green'],
'Quantity': [12, 22, 50, 65, 20],
'Price': [60, 100, 40, 55, 35]
}

dfn = pd.DataFrame(data)

# i. Find all rows with the label “Chilli”, Extract all columns.
chilli_rows = dfn[dfn['Item'] == 'Chilli']
print("All rows with the label 'Chilli':")
print(chilli_rows)

# ii. List 2nd, 3rd and 4th rows.


rows_2_3_4 = dfn.iloc[1:4] # iloc is used for positional indexing
print("\n2nd, 3rd and 4th rows:")
print(rows_2_3_4)
# iii. List only the columns Quantity and Price using loc.
quantity_price = dfn.loc[:, ['Quantity', 'Price']] # ':' selects all rows
print("\nColumns Quantity and Price:")
print(quantity_price)
```

### Explanation:

1. **Finding Rows with "Chilli"**:


We used a conditional statement to filter the DataFrame for rows where the 'Item'
column equals "Chilli".

2. **Listing 2nd, 3rd, and 4th Rows**:


The `iloc` function is used here to select specific rows by their position. The slice `1:4`
retrieves rows at indices 1, 2, and 3 (remembering that Python uses zero-based
indexing).

3. **Listing Only Quantity and Price Columns**:


The `loc` method is used to select specific columns. The `:` operator selects all rows,
while `['Quantity', 'Price']` specifies the columns to be retrieved.

### Output:

Running this code will produce the filtered DataFrame and lists as specified.
Q.35 To answer your questions regarding the `Salesman` table in SQL, here are the 5
corresponding SQL queries for each request:

### Given the Salesman Table:


```
+-------+-----------+---------+------------+----------+-------+
| Scode | Sname | Address | Dtofjoin | Sales | Areas |
+-------+-----------+---------+------------+----------+-------+
| 100 | Sushant | Delhi | 2017/09/29 | 5000.90 | East |
| 101 | Sushant | Gurgaon | 2018/01/01 | 7000.75 | East |
| 102 | Priya | Noida | 2018/04/25 | 3450.45 | West |
| 103 | Mohan | Delhi | 2018/11/03 | 6000.50 | North |
| 104 | Priyanshi | Delhi | 2019/12/15 | 8000.62 | North |
+-------+-----------+---------+------------+----------+-------+
```

### i. Display Sname and Sales of East and West areas.


```sql
SELECT Sname, Sales
FROM Salesman
WHERE Areas IN ('East', 'West');
```

### ii. Display the total Sales made in East Areas.


```sql
SELECT SUM(Sales) AS Total_Sales_East
FROM Salesman
WHERE Areas = 'East';
```

### iii. The command to display the Name of the Salesman along with the Sales amount
rounded off to one decimal point.
```sql
SELECT Sname, ROUND(Sales, 1) AS Rounded_Sales
FROM Salesman;
```

### iv. The command to display the length of salesman name.


```sql
SELECT Sname, LENGTH(Sname) AS Name_Length
FROM Salesman;
```

### Explanation of Queries:

1. **Displaying Sname and Sales of East and West areas**:


This query retrieves the names and sales figures for salesmen working in the East and
West areas using the `IN` clause to filter results.

2. **Calculating the total Sales in East Areas**:


This query calculates the total sales made by salesmen in the East area using the
`SUM` aggregate function.

3. **Displaying Salesman's Name with Rounded Off Sales**:


The `ROUND` function is used here to round off the sales amount to one decimal point
for easier readability and reporting.

4. **Displaying Length of Salesman Name**:


The `LENGTH` function calculates the length of each salesman’s name, returning an
additional column with this data alongside the names.
These queries will help Abhay, the Database Administrator, to efficiently retrieve and
analyze the data from the `Salesman` table.

You might also like