You are on page 1of 30

INFORMATION PRACTICES

…PRACTICAL FILE .…….


NAME: MANDEEP SINGH
CLASS : 12 [COMMERCE]
ROLL NO :
16

SUBMITTED TO: MANISHA PURI


CERTIFICATE
This is to certify that "MANDEEP" student
Informatics Practices, class - 12th
"commerce" 'B' has successfully completed
their Informatics Practices Practical
……………"PYTHON PROGRAMS’’……………..

ACKNOWLEDGEMENT
I would like to express my special thanks of gratitude
to my Informatics Practices teacher "Mrs. Manisha
Puri" for their able guidance and support in
completing my Project.

I would also like to extend my gratitude to the


Principal Sir "Mr. Shashi Kant" for providing me with
all the facility that was required.

INDEX
1. Write a program to create an empty series

2. Write a program to create a series showing section names and contribution made by them using
list.
section names and contribution made by them using list.'''

3. Number of students in class 11 and 12 in three streams('sci','comm','arts') are stored in two


series C11 AND 12. Write a program to find total number of students in class 11 and 12 stream
wise.
4. Write a program to arrange the element of a series with values 13,9,12,78 in ascending order.
With values 13,9,12,78 in ascending order.'''

5. Write code to display those element of series which are less than 5000 from a series that stores
the areas.
6. Write a program to display number of rows in series

7. Write a program to display first two rows and last two rows of a series

8. Write a program to create a series using three different words "pyton", 'is, 'a' ,'language’
"pyton", 'is, 'a' ,'language'''

9. Write a program to create a series showing the section names and contribution made by them
using DICTIONARY
10. WRITE A PROGRAM TO CREATE A SERIES USING AN NDARRAY THAT HAS 5
ELEMENTS IN THE RANGE 24 TO 64
11. Write a program to create dataframe for following and display column hospital and school
using dictionary:

Population hospital school


Delhi 100000 200 8000
Mumbai 1200000 500 10000
Kolkatta 230000 150 7000
12. Write a program to create dataframe for following:( using nested list)
A B C
0 1 2 3
1 4 5 6

13. Write a program to display total number of rows and columns in following:
Data frame game
G1 G2 G3
0 101 105 106
1 400 500 600
2 300 50 80

14. Write a program to change index values 0,1,2 to M1,M3,M4 in following dataframe game
G1 G2 G3
0 101 105 106
1 400 500 600
2 300 50 80
15. Write a program to display those whose total score are more than 80 in following dataframe
Name Score
0 Anil 67
1 Sagar 89
2 sunil 90
3 aman 56
16. Create a line chart representing following data:
App name Price
FUN RUN 60
ANGRY BIRD 50
TEEN TITAN 90
MARVEL COMICS 120
COLOR ME 150
X- AXIS SHOULD BE “APP NAME” Y- AXIS SHOULD BE PRICE

17. Draw a line chart to represent sales data of various models of cars in a month
18. Draw a bar chart representing population of different cities. Colour of bar should be
green. Xlabel cities and ylabel population

INFORMATION PRACTICES
……PRACTICAL FILE.…….
VISUALISATION

QUESTION 1
import matplotlib.pyplot as plt
a=['mandeep','sukhjeet','harsh','vansh']
b=[75,89,87,89]
plt.barh (a,b)
plt.show()

QUESTION 2
import matplotlib.pyplot as pl
a=[1,2,3,4]
b=[2,4,6,8]
pl.xlable("same value")
pl.ylabel("double value")
pl.title("chart")
pl.plot(a,b)
pl.show()

QUESTION 3
import matplotlib.pyplot as pl
import numpy as np
D=['mon','tue','wed','thu','fri','sat']
S=['A','B','C','D','E','F']
A=[8000,12000,9800,11200,15500,7300]
L=len(A)
X=np.arange(L)
pl.plot(X,A,marker='o',ls='dashed')
#part A
pl.show()
#part B
pl.plot(w,a)
pl.show()

PRACTICAL FILE
PYTHON PANDAS

Question 1
import pandas as pd
a=pd.Series ((4,6,8,10))
print("Series object")
print(a)
output
Series object
0 4
1 6
2 8
3 10
dtype: int64
Question 2
WRITE A PROGRAM TO CREATE AN EMPTY SERIES.
import pandas as pd
s1 = pd.Series()
print(s1)
OUTPUT:
Series([], dtype: float64)
Question 3
WRITE A PROGRAM TO CREATE A SERIES SHOWING
SECTION NAMES AND CONTRIBUTION MADE BY THEM
USING LIST.
import pandas as pd

S = ['A','B','C','D']

C = [3500,1200,2300,1500]

S2 = pd.Series(data = C, index = S)

print(S2)

OUTPUT

Series([], dtype: float64)

A 3500

B 1200

C 2300

D 1500

dtype: int64
Question 4
Number of students in class 11 and 12 in three
streams('sci','comm','arts') are stored in two series C11
AND 12. Write a program to find total number of students
in class 11 and 12 stream wise.

import pandas as pd
N11 = [24,45,67]
N12 = [56,67,89]
S = ['sci','comm','arts']
S11 = pd.Series(data = N11,index = S)
S12 = pd.Series(data = N12,index = S)
print(S11)
print(S12)
print(S11+S12)

dtype: int64

OUTPUT:

comm 67

arts 89
dtype: int64

sci 80

comm 112

arts 156

4)Write a program to arrange the element of a series with


values 13,9,12,78 in ascending order.
import pandas as pd

L = [ 13,9,12,78]

S = pd.Series(data = L)

print(S)

print(S.sort_values())

OUTPUT:

0 13

1 9

2 12

3 78

dtype: int64

1 9

2 12

0 13

3 78

dtype: int64
5) Write code to display those element of series which are
less than 5000 from a series that stores the areas.
import pandas as pd
A = [1000,100,345,6000]
S2 = pd.Series(data = A)
print(S2[S2<5000])
OUTPUT
dtype: int64
0 1000
1 100
2 345
dtype: int64

6) Write a program to display number of rows in series


import pandas as pd
L = [1,2,3,4]
s = pd.Series(data=L)
print(s.shape)
OUTPUT
(4,)
7) Write a program to display first two rows and last two
rows of a series
import pandas as pd
L = [1,2,3,4,5,6,7,8,9,10]
s = pd.Series(data=L)
print(s.head(2))
print(s.tail(2))
OUTPUT
0 1
1 2
dtype: int64
8 9
9 10
dtype: int64
8) Write a program to create a series using three different
words "python", 'is, 'a' ,'language’
import pandas as pd

L = ["python", 'is', 'a' ,'language']


S5 = pd.Series(data = L)
print(S5)
OUTPUT
0 python
1 is
2 a
3 language
dtype: object
9) Write a program to create a series showing the section
names and contribution made by them using DICTIONARY.
import pandas as pd
D = {'A':3500,'B':1200,'C':2300,'D':1500}
S3 = pd.Series(data = D)
print(S3)
OUTPUT
A 3500
B 1200
C 2300
D 1500
dtype: int64
10) WRITE A PROGRAM TO CREATE A SERIES
USING AN NDARRAY THAT HAS 5 ELEMENTS IN THE
RANGE 24 TO 64
import pandas as pd
importnumpyas np
n = np.linspace(24,64,5)
S6 = pd.Series(data = n)
print(S6)
OUTPUT
0 24.0
1 34.0
2 44.0
3 54.0
4 64.0
dtype: float64
11) Write a program to create dataframe for following
and display column hospital and school using dictionary
Population hospital school
Delhi 100000 200 8000
Mumbai 1200000 500 10000
Kolkatta 230000 150 7000
import pandas as pd

d1 = {'population':{'Delhi':100000,'Mumbai':1200000,'Kolkatta':230000}

,'hospital':{'Delhi':200,'Mumbai':500,'Kolkatta':150},

'school':{'Delhi':8000,'Mumbai':10000,'Kolkatta':7000}}

df2 = pd.DataFrame(d1)

print(df2)

OUTPUT

population hospital school

Delhi 100000 200 8000

Mumbai 1200000 500 10000

Kolkatta 230000 150 7000


12) Write a program to create dataframe for following:
( using nested list)
A B C
0 1 2 3
1 4 5 6
importnumpyas np
import pandas as pd
L = [[1,2,3],[4,5,6]]
DF2 = pd.DataFrame(L,columns = ['A','B','C'])
print(DF2)
OUTPUT
A B C
0 1 2 3
1 4 5 6
13) Write a program to display total number of rows and
columns in following
Data frame game
G1 G2 G3
0 101 105 106
1 400 500 600
2 300 50 80
import pandas as pd

importnumpyas np

D = {'G1':[101,400,300],'G2':[105,500,50],'G3':[106,600,80]}

DF = pd.DataFrame(D)

print(DF.shape)

OUTPUT

(3, 3)
14) Write a program to change index values 0,1,2 to M1,M3,M4
in following dataframe game
G1 G2 G3
0 101 105 106
1 400 500 600
2 300 50 80
importnumpyas np

import pandas as pd

D = {'G1':[101,400,300],'G2':[105,500,50],'G3':[106,600,80]}

DF = pd.DataFrame(D)

DF.index=['M1','M3','M4']

print(DF)

OUTPUT

G1 G2 G3

M1 101 105 106

M3 400 500 600

M4 300 50 80
15) Write a program to display those whose total score are
more than 80 in following dataframe
NAME SCORE
0 ANIL 67
1 SAGAR 89
2 SUNIL 90
3 AMAN 56
import numpyas np

import pandas as pd

d={'NAME':['Anil','Sagar','Sunil','Aman'], 'SCORE':[67,89,90,56]}

A=pd.DataFrame(d)

sh=A['SCORE']>=80

print(A[sh])

OUTPUT

NAME SCORE

1 Sagar 89

2 Sunil 90
16) Create a line chart representing following data:

App name Price

FUN RUN 60

ANGRY BIRD 50

TEEN TITAN 90

MARVEL COMICS 120

COLOR ME 150

X- AXIS SHOULD BE “APP NAME” Y- AXIS SHOULD BE PRICE

plt import matplotlib.pyplot as

app = ['FUNRUN','ANGRYBIRD','TEENTITAN','MARVEL COMICS','COLOR ME']

P = [60,50,90,120,150]

plt.xlabel("APPNAME")

plt.ylabel("price")

plt.plot(app,P,'c',marker='h')

plt.show()

17) Draw a line chart to represent sales data of various models


of cars in a month.
import matplotlib.pyplot as plt
sales=[120000,400000,500000,400000]
model=['alto','innova','kreta','drize']
plt.plot(model,sales,'y',ls='dashed')
plt.ylabel("sales of car")
plt.xlabel("models")
plt.show()
18) Draw a bar chart representing population of different cities.
Colour of bar should be green. Xlabel cities and ylabel
population
import matplotlib.pyplot as plt
c=['bombay','delhi','chandigarh']
p=[200000,400000,100000]
pl.plot(c,p,color=['r','g','b'])
pl.xlabel("city")
pl.ylabel("population")
pl.title("senses")
pl.show()

MY SQL
1 Command to create database

2 command to open database

3 command to create table

4 command to insert rows

5 command to add new column remarks char(18)

6 command to insert row with null value in marks


7command to display all the details of a table

8 SQL query to display name and class of those students


whose marks are more than 50

9 display details of all students in des order of marks


10 display name and grade of those students whose
marks are between 50 and 8

11 display details of those students whose marks are not


given

12 display grade and name of those students whose name


starts with m and marks are more than 50

13 Display count of students class wise


14 display maximum,mimimum,avg,total of marks

15 display all names in lowe case

You might also like