QP - Info - Gr.12 - June Test - 2021 - MS

You might also like

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

Mid Term Test – June 2021

Subject(065)
Grade : 12 MARKING SCHEME Time: 1 ½ Hours
Date: 3/6/2021 Max. Marks : 40

Test Instructions:
(i) All questions are compulsory.
(ii) This question paper consists of 15 MCQ questions and 5 descriptive questions.
(iii) MCQs numbered (1-15) carry 2 marks each and Descriptive questions numbered (16-20)
carry 2 marks each.
(iv) Question no. 16 – 20 (scanning and uploading part)
(v) Programming language : Python

QNo QUESTIONS MARK


1Grade:What
12 is the full form
Subject :of NumPy? (Code) Date: 2
.06.2020
A. NumberedPython.
B. NumericalArray.
C. NumericalPython
D. NumberPythonArray

2 What will be the output of the following code? 2

import numpy as np
Arr = np.arange(1,11)
print(Arr[10:2:-2])

Output 1 Output 2

[ 10 8 6 4 2] [ 4 6 8 10]

Output 3 Output 4

[10 8 6 4] [2 4 6 8 10]

A. Output 2
B. Output 3
C. Output 4
D. Output 1

1
3 What would be the output? 2

Output 1 Output 2

[ 4 9 16 25] [1. 2. 3. 4.]


[1. 2. 3. 4.] [ 4 9 16 25]

Output 3 Output 4

[1 2 3 4] [ 4 9 16 25]
[ 4 9 16 25] [1 2 3 4 ]

A. Output 1
B. Output 3
C. Output 4
D. Output 2

4 Which of the following 2 line combinations have errors? 2

A. line 2 and line 5


B. line 2 and line 3
C. line 4 and line 6
D. line 5 and line 3

5 Which of the following options can complete line 6? 2

2
A. np.median(x)
B. np.median()
C. x.median()
D. numpy.median(x)

6 What would be the output? 2

Output 1 Output 2

8 42 0 10
9 48 1 15
dtype: int32 2 18
0 10 3 22
1 15 4 55
2 18 dtype: int32
3 22 8 48
4 55 9 97
dtype: int32 dtype: int32

Output 3 Output 4

0 10 1 18
1 18 2 22
2 22 3 88
3 88 4 77
4 77 5 40
dtype: int32 dtype: int32
8 98 8 98
9 20 9 20
dtype: int32 dtype: int32

A. Output 1
B. Output 4
C. Output 3
D. Output 2

3
7 Which of the following 2 line combinations have errors? 2

A. line 2 and line 6


B. line 5 and line 4
C. line 2 and line 5
D. line 4 and line 6

8 Given the following code and the Output, Fill in the blanks (blank1 & blank2). 2

and the output :

Countries
India NewDelhi
USA WashingtonDC
UK London
France Paris
dtype: object
4

A. blank1 is index.name and blank2 is size


B. blank1 is name and blank2 is itemsize
C. blank1 is indexname and item.size
D. blank1 is values and blank2 is itemsize

9 Which line combinations have error? 2

A. line 3 and line 6


B. line 1 and line 4
C. line 2 and line 5
D. line 2 and line 4

4
10 Which of the following options is correct? 2

Statement 1: A Series is a two-dimensional labeled data structure like a


spreadsheet.
Statement 2: The two common ways of accessing the elements of a series are
Indexing and Slicing.

A. Statement 1 is False & Statement 2 is True


B. Statement 1 is False & Statement 2 is False
C. Statement 1 is True & Statement 2 is True
D. Statement 1 is True & Statement 2 is False

11 What will be the output of the following code? 2

Output 1 Output 2

Player1 Player2 Player1 Player2


Match1 45 67 Match1 45 67
Match2 77 87 Match3 45 77
Match3 45 77

Output 3 Output 4

Player1 Player2 Player1 Player2


Match2 77 87 Match1 45 67
Match3 45 77 Match2 77 87

A. Output 4
B. Output 1
C. Output 2
D. Output 3

12 Given the following code and the Output, Fill in the blanks (blank1 & blank2). 2

5
and the output :

308
0 2
1 2
2 2
3 2
4 2
dtype: int64

A. blank1 is score_df.sum() and blank2 is score_df.count( )


B. blank1 is score_df['Score'].sum() and blank2 is score_df.count(axis=1)
C. blank1 is score_df['Score'].sum(axis=1) and blank2 is score_df.count(0)
D. blank1 is score_df.sum() and blank2 is score_df.count(axis=0)

13 Which of the following options is correct? 2

Statement 1: Data can be loaded in a DataFrame from a file on the disk by using
Pandas read_csv function.
Statement 2: DataFrame.loc[ ] is used for label based indexing of rows in
DataFrames.

A. Statement 1 is False & Statement 2 is True


B. Statement 1 is False & Statement 2 is False
C. Statement 1 is True & Statement 2 is True
D. Statement 1 is True & Statement 2 is False

14 What would be the output? 2

6
Output 1 Output 2

Name Salary Name Salary


0 Sachin 2000 0 Vinod 5000
2 Rejesh 4000 2 Sharma 7000
Output 3 Output 4

Name Salary Name Salary


1 Sachin 5000 1 Vinod 5000
3 Rejesh 7000 3 Sharma 7000

A. Output 3
B. Output 2
C. Output 1
D. Output 4

15 What would be the outcome of the following statement where DF is a dataframe 2


and v is a list of 3 values ? DF already has columns Eno, Ename, Q2, Q3.

DF.insert(loc=2, column= ' Q1 ', value=v)

A. add a column called Q1 after column Eno.


B. add a column called Q1 before column Q2.
C. insert a column called Q1 after column Q2.
D. insert a column called Q1 before column Q3.

16 Write the code to create the Series given below: 2

Ans:
import pandas as pd
sales=pd.Series([2000,1000,3000,5000],
index=['Q1','Q2','Q3','Q4'])
sales.name="Sales"
print(sales)

Each error deduct ½ mark


Total : 2 marks

17 What would be the output? 2

7
Ans:

Each line of ouput : ½ mark


Total : 2 marks

18 Write the code to create the DataFrame given below: 2

Ans:
import pandas as pd
data = {"Year": [2010,2010,2012,2012],
"Month": ["Jan","Mar","Jan","Dec"],
"Passengers": [25,50,35,65]}
df=pd.DataFrame(data, index = ["Air India",
"Indigo","Spicejet","emirates"])
print(df)
Each error deduct ½ mark
Total : 2 marks

19 What would be the output of the following code? 2


import pandas as pd
d={'Prod':['Apple','Pear','Banana','Grapes'],
'Qty':[100,150,200,250],
'Cost':[1000,1500,1200,900] }
df=pd.DataFrame(d)
print(df['Prod'][df['Qty']>200])
print(df['Cost'].mean())

Ans:
3 Grapes
1150.0
Each output 1 mark
Total 2 marks

20 Consider the following code of Dataframes df1 and df2 and answer the questions 2
given below:

8
import pandas as pd
d1={'mark1':[17,18,16,15],
'mark2':[16,15,14,19]}
d2={'mark1':[15,17,16,19],
'mark2':[14,13,17,19]}
df1=pd.DataFrame(d1)
df2=pd.DataFrame(d2)

i) Write the code to add both the DataFrames df1 anf df2 into a new
DataFrame df3.
ii) Write the code to rename the index of df2 from 0,1,2,3 to st1,st2,st3,st4.

Ans:
i) # to add both dataframes into df3
df3=df1.append(df2)

ii) # to rename the index of df2 from 0,1,2,3 to st1,st2,st3,st4


df2=df2.rename(index={0:'st1',1:'st2',2:'st3',3:'st4'})

Each part : 1 mark


Total : 2 marks

*******************************************************************

You might also like