Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

Computer Science NCERT – CBSE – Practical Programmes – For Class XII – 2023-24

Rating
-
Sold
-
Pages
18
Grade
A+
Uploaded on
02-07-2024
Written in
2023/2024

Computer Science NCERT – CBSE – Practical Programmes – For Class XII – 2023-24

Institution
Course

Content preview

12IP-PRACTICAL MODEL QUESTIONS (23-24)
A. Write the code to create the series ‘serObj’ and answer the questions followed.
Jan 31
Feb 28
Mar 31
Apr 30
1. Write the command to add one row: ‘May’ – 31
2. Write the command to update Feb to 29
3. Write the command to change index to 1,2,3,4,5 in place of Jan,Feb,Mar, Apr and May.
4. Write a command to print a month name having number of days less than 31.
5. Write the output:
a) print(serObj<30)
b) print(serObj + 3)
ANSWER
import pandas as pd
serObj=pd.Series([31,28,31,30], index=['Jan','Feb','Mar','Apr'])
serObj['May']=31
serObj['Feb']=29
serObj.index=[1,2,3,4,5]
serObj[serObj<31]
print(serObj < 30)
print(serObj+3)
print(serObj)




B. Write the code to create a DataFrame ‘RESULT’ and answer the questions followed.
Col1 Col2 Col3
T1 100.0 100.0 60.0
T2 95.8 100.0 57.48
T3 NaN 100.0 53.58
1
Page




T4 82.0 85.4 49.20
SHUNMUGA SUNDARAM S, A.M.I.E, M.E/CSE +91-9994548619

, 1. Write a command to add one row T5 with values 75.6, 98.6, 56.0
2. Write a command to add one column Total = col1+col2+col3
3. Write a command to change the column names Col1 to Maths, Col2 to Science, Col3 to SST.
4. Write a command to print Score of Maths and Science only.
5. Write a command to update NaN to 85.0 in T3 Row and Col1
ANSWER
import numpy as np
data = {'Col1': [100.0, 95.8, np.nan, 82.0],
'Col2': [100.0, 100.0, 100.0, 85.4],
'Col3': [60.0, 57.48, 53.48, 49.20]}
index = ['T1', 'T2', 'T3', 'T4']
RESULT = pd.DataFrame(data, index)
print(RESULT)
RESULT.loc['T5'] = [75.6, 98.6, 56.0] #1
RESULT['Total'] = RESULT['Col1'] +RESULT['Col2'] + RESULT['Col3'] #2
RESULT = RESULT.rename(columns={'Col1': 'Maths',
'Col2': 'Science',
'Col3': 'SST'}) #3
print(RESULT)
print(RESULT[['Maths', 'Science']]) #4
RESULT.at['T3', 'Maths'] = 85.0 #5
print(RESULT)




C. Write the code to create a DataFrame ‘df’ and answer the questions followed.
Maths Science SST
Amit 100 100.0 60.0
Mohan 95 50.0 57.48
Sudha 85 90.0 53.58
1. Write a command to add one row ‘Chris’ with values 75.6, 98.6, 56.6
2




2. Write a command to add one column Total = Maths+ Science + SST
Page




SHUNMUGA SUNDARAM S, A.M.I.E, M.E/CSE +91-9994548619

, 3. Write a command to print Score of Maths and Science only.
4. Write a command to update marks of Science of Sudha to 85.0
5. Write a command to delete a row – Mohan
ANSWER
import pandas as pd
data={'Maths':{'Amit':100,'Mohan':95,'Sudha':85},
'Science':{'Amit':100,'Mohan':50,'Sudha':90},
'SST':{'Amit':60,'Mohan':57.48,'Sudha':53.58}
}
df=pd.DataFrame(data)
print(df)
df.loc['Chris']=[75.6,98.6,56.6] #1
df['Total']=df['Maths']+df['Science']+df['SST'] #2
print(df[['Maths','Science']]) #3
df.at['Sudha','Science']=85.0 #4 or
df.iat[2,1]=85.0 #4
print(df)
df.drop(['Mohan'],inplace=True,axis=0) #5
print(df)




D. Consider the following DataFrame df and answer the given questions
Rollno Name UT1 UT2 UT3 UT4
1 Prerna Singh 24 24 20 22
2 Manish Arora 18 17 19 22
3 Tanish Goel 20 22 18 24
4 Falguni Jain 22 20 24 20
5 Kanika Bhatnagar 15 20 18 22
1. Write the command to print top two rows.
2. Write the command to print last two rows.
3. Write the command to add one more column in dataframe df name total.
Total = UT1+UT2+UT3+UT4
4. Write the command to display the rows having roll no is 4
3
Page




5. Write the command will display the column labels of the DataFrame?
SHUNMUGA SUNDARAM S, A.M.I.E, M.E/CSE +91-9994548619

Written for

Course

Document information

Uploaded on
July 2, 2024
Number of pages
18
Written in
2023/2024
Type
Exam (elaborations)
Contains
Only questions

Subjects

$5.19
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
kbzone

Get to know the seller

Seller avatar
kbzone ICSE
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
284
Last sold
-
Notes On All Subjects

A Store where Notes, Presentations, Questions &amp; Answers, Classnotes, Study mqaterials and Studyguides are available at a very nominal preice. The notes are very useful for both the Students and Teachers.

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions