0% found this document useful (0 votes)
23 views

Class 12 IP Practice Assignment Series 3

Uploaded by

Bhavya Bhatt
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)
23 views

Class 12 IP Practice Assignment Series 3

Uploaded by

Bhavya Bhatt
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/ 3

Write following MCQ Question Answer in your Notebook datewise.

Series-3
Revision Practice MCQ Unsolved Questions 08-09-2021
Class 12
Topic- Pandas DataFrame Creation, adding a new row and a new column, delete a row and delete a
column, head() and tail()
Subject IP
Q1. To create following emp dataframe, so select correct python code for this:-
emp
eid ename eheight
0 e1 john 25
1 e2 smith 30
2 e3 peter 22
import pandas as pd
a. emp=DataFrame(,‘eid’:*‘e1’, ‘e2’, ‘e3’+, ‘ename’ : *‘john’,’smith’,’peter’+, ‘eheight’:*25,30,22+-)
b. emp=pd.dataframe(,‘eid’:*‘e1’, ‘e2’, ‘e3’+, ‘ename’ : *‘john’,’smith’,’peter’+, ‘eheight’:*25,30,22+-)
c. emp=pd.DataFrame(,‘eid’:*‘e1’, ‘e2’, ‘e3’+, ‘ename’ : *‘john’,’smith’,’peter’+, ‘eheight’:*25,30,22+-)

Q2. To add a new row following in above emp dataframe, So select the correct python code for this.
eid ename eheight
3 e4 akbar 31
a. emp.append({'eid': 'e4', 'ename' : 'akbar', 'eheight' : 31}, ignore_index=True )
b. emp=emp.append({'eid': 'e4', 'ename' : 'akbar', 'eheight' : 31})
c. emp=emp.append({'eid': 'e4', 'ename' : 'akbar', 'eheight' : 31}, ignore_index=True )

Q3. To add a new row following in above emp dataframe, So select the correct python code for this.
eid ename eheight
4 e5 robert 45
a. emp=emp.append({'eid': 'e5', 'ename' : 'robert', 'eheight' : 45}, ignore_index=True )
b. emp.append({'eid': 'e5', 'ename' : 'robert', 'eheight' : 45}, ignore_index=True )
c. emp=emp.append({'eid': 'e5', 'ename' : 'robert', 'eheight' : 45})

Q4. To add a new row following in above emp dataframe, So select the correct python code for this.
eid ename eheight
5 e6 vinit 38
a. emp.append({'eid': 'e6', 'ename' : 'robert', 'vinit' : 38}, ignore_index=True )
b. emp=emp.append({'eid': 'e6', 'ename' : 'vinit', 'eheight' : 38}, ignore_index=True )
c. emp=emp.append({'eid': 'e6', 'ename' : 'vinit', 'eheight' : 38})

Q5. To add a new column following in above emp dataframe, So select the correct python code for this.
eweight
40
45
42
60
58
a. ['weight']=[40,45,42,60,58]
b. emp['weight']=[40,45,42,60,58]
c. emp=[40,45,42,60,58]

Q6. To add a new column following in above emp dataframe, So select the correct python code for this.
ecity
‘paris’
‘mosco’
‘spain’
‘london’
‘new york’
a. emp['city']=[’paris’,’mosco’,’spain’,’london’,’new york’]
b. ['city']=[’paris’,’mosco’,’spain’,’london’,’new york’]
c. emp=[’paris’,’mosco’,’spain’,’london’,’new york’]

Q7. To delete a first row of above emp dataframe, so select the correct python code for this.
a. emp=emp.drop(0)
b. emp.drop(0)
c. drop(0)

Q8. To delete a second row of above emp dataframe, so select the correct python code for this.
a. drop(1)
b. emp.drop(1)
c. emp=emp.drop(1)

Q9. To delete a third row of above emp dataframe, so select the correct python code for this.
a. drop(2)
b. emp=emp.drop(2)
c. emp.drop(2)

Q10. To delete a eid column of above emp dataframe, so select the correct python code for this.
a. emp('eid')
b. emp.pop('eid')
c. pop('eid')

Q11. To delete a ecity column of above emp dataframe, so select the correct python code for this.
a. emp.pop('ecity')
b. emp('ecity')
c. pop('ecity')

Q12. To delete a ename column of above emp dataframe, so select the correct python code for this.
a. emp.pop('ename')
b. del emp[‘ename’]
c. Both will give same result to delete ename column of emp dataframe.

Q13. To display only top two rows directly of above emp dataframe, so select the correct python code for
this.
a. print(emp.head(2))
b. print(emp.top(2))
c. print(emp.start(2))

Q14. To display only top three rows directly of above emp dataframe, so select the correct python code for
this.
a. print(emp.start(3))
b. print(emp.top(3))
c. print(emp.head(3))

Q15. To display only bottom two rows directly of above emp dataframe, so select the correct python code
for this.
a. print(emp.end(2))
b. print(emp.bottom(2))
c. print(emp.tail(2))

Q16. To display only bottom three rows directly of above emp dataframe, so select the correct python
code for this.
a. print(emp.end(3))
b. print(emp.tail(3))
c. print(emp.bottom(3))

Q17. To display emp dataframe, so select the correct python code for this:
a. print(emp)
b. emp
c. employee

Q18. To display only eid column of emp dataframe, so select the correct python code for this:
a. print(emp)
b. print(emp.eid)
c. print(eid)

Q19. To display only ename column of emp dataframe, so select the correct python code for this:
a. print(ename)
b. print(emp[‘ename’])
c. print([‘ename’])

Q20. To display only eheight column of emp dataframe, so select the correct python code for this:
a. print(eheight)
b. print(emp.loc[: , ‘eheight’])
c. print([‘eheight’])

Previous MCQ Question pdf file

Date Pdf file link


06-09-2021 Class 12 IP Practice Assignment Series 1
07-09-2021 Class 12 IP Practice Assignment Series 2

You might also like