12 Ip Set B Anskey
12 Ip Set B Anskey
i. **To retrieve the length of the given string "CBSE BOARD SQP @ 2023!", which
SQL function should you use?**
- **c. LENGTH()**
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.
**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
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
```
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:
```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)
```python
import pandas as pd
- **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.
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
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
```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
### Output
When you run this code, the output will be:
```
California
```
```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):
```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;
```
```sql
-- Add a new column Plan_Start_Date of type DATE
ALTER TABLE Nutrients
ADD Plan_Start_Date DATE;
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.
- **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.
**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.
- **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.
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;
```
- **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.
- **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;
```
- **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:
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:
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.
**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.
**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
Imagine you receive an email that looks like it is from your bank. The email states:
---
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.
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.
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.
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.
### 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:
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.
### Conclusion
```python
import pandas as pd
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)
### Explanation:
### 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:
### 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;
```