You are on page 1of 9

Write a program to generate a series of marks of 10 students.

Give grace marks up to 3 marks of those


who are having marks between 30 to 33 marks and print the new list of the marks. 

Solution:

import pandas as pd

std_marks = []

for i in range(1,11):

m = int(input("Enter the marks:"))

std_marks.append(m)

s = pd.Series(index=range(1201,1211),data=std_marks)

s[s==32]=s+1

s[s==31]=s+2

s[s==30]=s+3

print("New List is:")

print(s[s>=33])

If you are looking for pandas series programs follow the below given link:

Pandas Series practical programs

Pandas Dataframe
I have taken question from pandas dataframe for 3 marks. Here

Consider the following data for :      

BookID Subject BookTitle Class Publisher Price

B0001 Computer Science NCERT Computer Science XII NCERT 270

B0002 Computer Science Move fast with computer science XII Dhanpat Rai 340
B0003 Computer Applications Sample Papers X BPB 120

B0004 Informatics Practices NCERT Computer Science XII NCERT 270

B0005 Artificial Intelligence Artificial Intelligence IX KIPS 340

B0006 Informatics Practices CBSE Questions Bank XII Oswal Books 299

1. Create a dataframe using lists.                                                                                           1


2. Display books for class XII.                                                                                                         1
3. Display the books whose price is more than 250.                                                                         1
4. Plot these data on line chart.                                                                                                         3

Code for 1,2, & 3.

import pandas as pd

import matplotlib.pyplot as mpp

#Answer 1

data={'BookID':['B0001','B0002','B0003','B0004','B0005','B0006'],\

'Subject':['Computer Science','Computer Science','Computer Appllications',\

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

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

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

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

books=pd.DataFrame(data)

#Asnwer 2
print("Class XII Books:")

print(books[books['Class']=='XII'].to_string(header=False,index=False))

print("***********************************************************")

#Asnwer 3

print("Books having price more than 250")

print(books[books['Price']>250].to_string(header=False,index=False))

#Answer 4

books.plot(x='Subject',y='Price',kind='bar')

mpp.show()

Download the python code in .py

Download Python Code

MySQL
Consider the following table and write answers for given questions below:

RollNo Name Class DOB Gender City Marks

1 Naman XII 1995-05-09 M Anand 453

2 Nandini X 1997-04-08 F Baroda 551

3 Nakshatra X 1997-03-02 F Baroda 553

4 Shailesh XI 1995-04-07 M Surat 458

5 Trisha XII 1996-04-01 F Anand 430


6 Manisha XII 1995-02-05 F Anand 530

7 Hetvee XII 1995-08-17 F Junagadh 555

8 Neel X 1997-10-19 M Godhara 559

9 Mayur XII 1996-12-04 M Surat 570

10 Dolin XII 1994-11-02 M Anand 585

Write SQL statements for the following based on table Garments:

1. Create above table in MySQL.


2. Insert records.
3. To display the detail of class XII students in descending order of their marks.
4. Display all the details of students in ascending order of name.
5. Find the maximum marks of the student for each class.
6. Count the students class wise is display only those number who is more than 2.
7. Display unique cities from the table.

Solution:

1 Create table:

create table students

(rollno int(4) primary key,

name varchar(20) not null,

class varchar(4),

dob date,

gender char(1),

city varchar(20),

marks float);

2 Insert records:
insert into students values

(1, 'Naman', 'XII','1995/05/09','M','Anand',453)

Insert all records simimlarly.

3 display the detail of class XII students in descending order of their marks

select * from students order by marks desc;

4 Display all the details of students in ascending order of name

select * from students order by name asc

5 Find the maximum marks of the student for each class

select class,max(marks) from students group by class

6 Count the students class wise is display only those number who is more than 2

select class,count(*) from students group by class having count(*)>2;

7 Display unique cities from the table

select distinct city from students;

Q3. Practical Records                                                                                                           5

The practical file needs to be checked and marks will be given accordingly.

Q4. Project Work                                                                                                                  5

The project work report should be made as per the guideline. Follow this link to download projects for
informatics practices with code and solution.

Download Projects Inofrmatics Practices Class 12

Q5. Viva Voce                                                                                                  5

Viva questions can be asked by the external examiner.

Solution Informatics Practices Practical Question


Paper Class 12 Set 2
Let us see solution for Inforamtics Practices practical question paper class 12 set 2.

Python Program
Q 1 Write a program in python to create the following dataframe named “country” storing the following
details:

  cname City billamt Tran_date

1001 Shruti Ahmedabad 9500 2010-10-01

1002 Tushar Baroda 5300 2010-01-04

1003 Jay Surat 4550 2009-03-01

1004 Sameer Ahmedabad 4000 2009-04-01

1005 Mayank Surat 8500 2008-08-05

1006 Meena Baroda 4300 2008-08-06

1007 Dhairya Ahmedabad 3000 2009-10-10

Considering the above dataframe answer the following queries by writing appropriate command in python
pandas.
i. Add a new column named discount which is 10% of their bill amount.
ii. Add a row with row index 1008 as Rohan,Bharuch,6000,2011-04-01.
iii. Now plot a bar chart depicting the customer name on x-axis and their corresponding
bill amount on y-axis, with appropriate Graph title, x-axis title, y-axis title, gridlines
and color etc.

Solution:

import pandas as pd

import matplotlib.pyplot as plt

d={'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']
}

customer=pd.DataFrame(d)

#Answer 1

customer['discount']=customer['billamt']*0.10

print(customer)

#Answer 2

customer.loc[1008]=['Rohan','Bharuch',6000,'2011-04-01',600]

print(customer)

#Answer 3

plt.bar(customer['cname'],customer['billamt'],color=['r','g','b','c','m','y','k'])

plt.title("Report",color='Red')

plt.xlabel("Customer Names",color='Blue')

plt.ylabel("Bill Amount",color='Magenta')

plt.show()

Download the Python code:

Download Python Code

MySQL
Q – 2 Create below table “staff” and insert all records.

  Sid sname designation salary dojoin

1001 Sagar PGT 87000 2010-11-02 Residential Section

1002 Ankit Clerk 24000 2010-04-01 Office

1003 Dhwani Clerk 22000 2009-01-05 Office

1004 Jenil PRT 34000 2009-07-25 Primary

1005 Roshni PGT 73000 2008-07-17 Senior

1006 Mital TGT 41000 2008-04-08 Middle

1007 Gagan Lab Assistant 24000 2009-11-23 Office

Answer the following sql queries:

i. Display the difference of maximum and minimum salary of each section.

select max(salary)-min(salary) from staff group by section;

ii. Display the staff name, designation and date of joining who joins in the month of July and April.

select sname,designation,dojoin from staff where monthname(dojoin) in ('April','July');

iii. Display the records of staff in their descending order of salary.

select * from staff order by salary desc;

iv. Show first 3 character of staff name.

select left(sname,3) from staff;

v. Display the records of staff who is working since last 12 years

select * from staff where year(now())-year(dojoin)=12;


vi. Display power of length of staff name

select power(length(sname),2) from staff;

You might also like