0% found this document useful (0 votes)
8 views4 pages

SSCE Practical Solutions

The document provides solutions for the SSCE Practical Examination 2023, including Python programs for generating marks and creating DataFrames using pandas. It also includes SQL queries for calculating salary differences, filtering staff details based on joining months, and ordering staff by salary. The solutions are structured in two sets, showcasing various data manipulation techniques in Python and SQL.

Uploaded by

aadityasaini1712
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)
8 views4 pages

SSCE Practical Solutions

The document provides solutions for the SSCE Practical Examination 2023, including Python programs for generating marks and creating DataFrames using pandas. It also includes SQL queries for calculating salary differences, filtering staff details based on joining months, and ordering staff by salary. The solutions are structured in two sets, showcasing various data manipulation techniques in Python and SQL.

Uploaded by

aadityasaini1712
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
You are on page 1/ 4

Solutions to SSCE Practical Examination 2023

Set 1: Solutions

Q1(a): Program to generate a series of marks and give grace marks:

```python

import pandas as pd

marks = pd.Series([28, 30, 31, 29, 33, 32, 25, 35, 40, 31])

marks = marks.apply(lambda x: x + 3 if 30 <= x <= 33 else x)

print(marks)

```

Q1(b): DataFrame creation and operations:

```python

import pandas as pd

data = {

'BookID': ['B0001', 'B0002', 'B0003', 'B0004', 'B0005', 'B0006'],

'Subject': ['Computer Science', 'Computer Science', 'Computer Applications',

'Informatics Practices', 'Artificial Intelligence', 'Informatics Practices'],

'BookTitle': ['NCERT Computer Science', 'Move fast with computer science',

'Sample Papers', 'NCERT Computer Science',

'Artificial Intelligence', 'CBSE Questions Bank'],

'Class': ['XII', 'XII', 'X', 'XII', 'IX', 'XII'],

'Publisher': ['NCERT', 'Dhanpat Rai', 'BPB', 'NCERT', 'KIPS', 'Oswal Books'],

'Price': [270, 340, 120, 270, 340, 299]

df = pd.DataFrame(data)
print(df[df['Class'] == 'XII'])

print(df[df['Price'] > 250])

df.plot.bar(x='BookTitle', y='Price')

```
Set 2: Solutions

Q1: Python Pandas DataFrame creation and operations:

```python

import pandas as pd

data = {

'cname': ['Shruti', 'Tushar', 'Jay', 'Sameer', 'Mayank', 'Meena', 'Dhairya'],

'City': ['Ahmedabad', 'Baroda', 'Surat', 'Ahmedabad', 'Surat', 'Baroda', 'Ahmedabad'],

'billamt': [9500, 5300, 4550, 4000, 8500, 4300, 3000],

'Tran_date': ['2010-10-01', '2010-01-04', '2009-03-01', '2009-04-01',

'2008-08-05', '2008-08-06', '2009-10-10']

df = pd.DataFrame(data)

df['discount'] = df['billamt'] * 0.1

new_row = {'cname': 'Rohan', 'City': 'Bharuch', 'billamt': 6000, 'Tran_date': '2011-04-01'}

df = df.append(new_row, ignore_index=True)

print(df)

df.plot.bar(x='cname', y='billamt', title='Customer Billing')

```

Q2: SQL Queries:

- Difference of max and min salary:

```sql

SELECT MAX(salary) - MIN(salary) AS diff FROM staff GROUP BY Section;

```

- Staff details who joined in July or April:

```sql

SELECT sname, designation, dojoin FROM staff


WHERE MONTH(dojoin) IN (4, 7);

```

- Descending order of salary:

```sql

SELECT * FROM staff ORDER BY salary DESC;

```

You might also like