Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

VELAMMAL NEW GEN SCHOOL, SURAPET

DPT 1
INFORMATICS PRACTICES
( Pure science)
01.04.2024
Total Marks : 25 Duration : 40 minutes

1 Krushn has created a datafrme using the following code: 2


import pandas as pd
dfruns=pd.DataFrame({'Sno':range (1,11,3), 'Runs': [ 25,36,74,12]})
print(dfruns.shape)

Write the output he will get for the above code.


a) (4,2) b) 4,2 c) [4,2] d) 4

2 Write a code to store data of 4 students details in a dataframe with following columns: name, age, current course, 2
university.
3 Aman store some data in the form of nested list. Later on he created dataframe "DF" from the list given below by 2
writing the following code. How many columns will be there in "DF".

L1 = [["Aman", "Cricket", "7th"], ["Ankit", "Hockey", "11th"], ["Sunita", "Basket ball", "9th"]]

import pandas as pd
L1 = [["Aman", "Cricket", "7th"], ["Ankit", "Hockey", "11th"], ["Sunita", "Basket ball", "9th"]]
DF = pd.DataFrame(L1)
print(DF)
4 Consider the following dataframe 'tempurature: 3
City max
0 Ahmedabad 31
2 Surat 29
3 Vadodara 32
Write suitable python code to:
a) Add new column min with these data: [25,22,19,28]
b) Write code to display no of rows
c) Write code to display no of columns
5 Fill in the blanks to produce the Output 3

import pandas as pd
L1 = ["Anil", "Ruby", "Raman", "Suman"]
L2 = [35, 56, 48, 85]
DF = pd.DataFrame([L1, L2], ___________________
print(DF)

OUTPUT
Ist IInd IIIrd IVth
A Anil Ruby Raman Suman
B 35 56 48 85
6 Observe the following code and write statements for the below give 4
import pandas as pd X
player1={'IG1':34, 'IG2': 0, 'IG3':23}
player2={'IG1':21, 'IG2':10, IG3':39}
pl={'p1':player1,'p2':player2}
df=pd.DataFrame(pl)
a) Display data of player scored more than 30 runs
b) Display all rows of first inning of all players
7 Write python code to create a dataframe by using following data: 4
[[201,'Manoj',4500], [202, 'Dhara', 3200], [203,'Mohini', 2300]]
i. Dataframe name should be cust
ii. Use column headings as: cust_id,cust_name and amount tutor

8 Consider the following dataframe df and the following questions: 5


Name House Score Rank
C1 Vipul Sardar 150 I
C2 Ramesh Vivekanand 143 II
C3 Shailesh Tagore 142 III

a. Write code to create above dataframe


b. Write code to display top 2 records
c. Write code to Add a column remark as Good for all
d. Write code to replace the house name Tagore with Aurobindo
e. Write Code to add a record with name Arun

You might also like