Questions

5 Marks Each

🎯

Test yourself on this topic

10 questions · timed · auto-graded

Question 15 Marks
Mr. Sharma is working with an IT company and he was provided with some data. On which he wants to do some operations but he is facing some problem, help him in resolving:

Amit Ram Sam Roja Monan
Maths 90 92 89 81 94
Science 91 81 91 71 95
Hindi 97 96 88 67 99

(a) He wants to add a new column with name of student ‘Prem’ in above data frame choose the right command to do so:

(b) He wants to set all the values to zero in data frame, choose the right command to do so:

Amit Ram Sam Roja Monan Prem
Maths 0 0 0 0 0 0
Science 0 0 0 0 0 0
Hindi 0 0 0 0 0 0

(i) DF=0 (ii) DF[]=0

(iii) DF[:]=0 (iv) DF[:]==0

(c) He want to delete the row of Science marks:

(i) DF.drop(‘Science’, axis=1)

(ii) Dfdrop(‘Science’, axis=0)

(iii) dfdrop(‘Science’, axis=-1)

(iv) dfdrop(‘Science’, axis==0)

(d) What will be the output of the given command?

DFindex=[‘A’,’B’,’C’]

(iv) Error, Index already exist cannot be overwrite

Amit Ram Sam Roja Manan
A 90 92 89 81 94
B 91 81 91 71 95
C 97 96 88 67 99

(e) The given code is to create another data frame, which he want to add to existing Data Frame choose the right command to do so:

Sheet1={

‘Aaradhya’: pdSeries([90, 91, 97],

index=[‘Maths’,’Science’,’Hindi’])}

S1=pdDataFrame(Sheet1)

(i) Df.append(S1,axis=0)

(ii) Df.append(S1)

(iii) Df.insert(S1)

(iv) Df.join(S1)

Answer
(a) (iii) DF[‘Prem’]=[89,78,76]

(b) (iii) DF[:]=0

(c) (ii) DFdrop(‘Science’, axis=0)

(d) (ii)

(e) Df.append(S1)

View full question & answer
Question 25 Marks
Mr. Naveen is working as data analyst. He was facing some problem related to panda’s library, help him in answering the given questions:
(a) He wants to display only 2 columns i.e. PNAME and Company, choose the right comman(d)

(b) He wants the given output, choose the right command:

(c) What will be the output of the given command? print(df.size)
(i) 20 (ii) 4
(iii) 24 (iv) 16
(d) Choose the command which will display the number of rows and columns of the above Dataframe
(i) print(dfshape)
(ii) print(dfshape()
(iii) print(dfrows,dfcolumns)
(iv) print(dfloc[],dfiloc[])
(e) What will be the output of the following command?
print(dfloc[2:4,’PNAME’])

Answer
(a) (iii) df[[‘PNAME’,’COMPANY’]](b) (ii) dfloc[dfPRICE<=20]
(c) (iv) 16
(d) (i) print(dfshape)
(e) (ii) 2 Sharpner
View full question & answer
Question 35 Marks
Mr. Sharma is working on pandas series and he is facing some problem while working on Series. Help him with few concepts by answering the given question:
He has created the series:

(a) He wanted the given output, which command will be appropriate to do the sam(e)

(b) Which command will give him the output as 5.
(i) s.index
(ii) s.size
(iii) s.values
(iv) None of the mentioned
(c) Assuming the changed structure, answer the question.

Which command will display the given output?
(i) s.head (2) (ii) s.top(2)
(iii) s.head() (iv) s.first(2)
(d) Choose the write output for the given command:
>>>print(stud1.count())
(i) 4 (ii) 3
(iii) 5 (iv) Error
(e) What is the name of the above Series?
(i) Student (ii) s
(iii) int64 (iv) float64
Answer
(a) (iii) s.index=[‘Amit’,’Ramesh’,’Mahesh’,’ john’,’Abdul’](b) (ii) s.size
(c) (i) s.head(2)
(d) (i) 4
(e) (ii) s
View full question & answer
Question 45 Marks
(a) Create the Dictionary Student with the following key and add the 5 values. Dictionary will be created from 4 different list:

Column Name Key
Student Number sno
Student Name sname
E-mail mail
Marks mark

(b) Create the data frame for the above specification containing index parameter along with column.

(c) Add a new column grade into above Data Frame with at least 3 methods.

(d) Insert the 2 rows.

(e) Create another Data Frame with two rows named DF2.

(f) Add this data frame to your existing data frame.

(g) Display the alternate rows.

(h) Display the name and marks of the students whose marks is greater than equal to 90.

(i) Fill all NaN in the data.

(j) Increase the marks by 10.

View full question & answer
Question 55 Marks
Answer the following question on the basis of given dataset:

a b c d
0 1 2 3 4
1 100 200 300 400
2 1000 2000 3000 4000

(i) To create the data frame for the above dictionary.

(ii) To print the dictionary.

(iii) To change the index of the above data frame 'a1','a2','a3'.

(iv) To change the columns headings to 'units','tens','hundred',' thousand'.

(v) To display the tens columns.

(vi) To create another datframe with values of thousand.

(vii) To use the iterrows() to display the complete records.

(viii) To display the column wise data using iteritems().

Write the output on the basis of the given data frame:

units tens hundred thousand
a1 1 2 3 4
a2 100 200 300 400
a3 1000 2000 3000 4000

View full question & answer
Question 65 Marks
Answer the questions given below based on the given dataset:

(i) To print the name of the libraries required.

(ii) To create the data frame for the above data.

(iii) To Display a summary of the basic information about this DataFrame and its data.

(iv) To display first 3 rows of the DataFramedf.

(v) Select just the 'animal' and 'age' columns from the DataFramedf

(vi) Select the data in rows [3, 4, 8] and in columns ['animal', 'age'].

(vii) Select only the rows where the number of visits is greater than 3.

(viii) Select the rows where the age is missing, i.e. is NaN.

(ix) Select the rows where the animal is a cat and the age is less than 3.

(x) Select the rows the age is between 2 and 4 (inclusive).

(xi) Change the age in row 'f' to 1.5.

(xii) Append a new row 'k' to df with your choice of values for each column. Then delete that row to return the original DataFrame.

(xiii) In the 'animal' column, change the 'snake' entries to 'python'.

View full question & answer
Question 75 Marks
Answer the question given below:

Country Expenditure GrowthRate UpdataDate GDP_Growth_rate
0 Australia 1287600000 25.00 2016-07 21.0
1 United States 989300000 24.56 2016-09 19.6

(i) Create the above file in Excel and write the command to create the data frame.

(ii) To print the dataframe.

(iii) To set the index to the column country in the above data frame.

(iv) To add the new data frame in previous question data frame also sort the result.

(v) To change the first row date to 2016-01 for UpdateDate column.

View full question & answer
Question 85 Marks
On the basis of the given data set, answer the questions below:

ExpenditureData={'Country': ['Brazil', 'India', 'United Kingdom', 'Nigeria', 'China','Pakistan'],

'Expenditure': [785300000, 530780000, 694582000, 130581000, 407191800, 4754000],

'GrowthRate': [15, 18.6, 13.79,14.87,20.86, 12.54]

'UpdateDate': ['2016-03', '2016-08', '2016-02', '2016-01','2016-09','2016-05']}

Country Expenditure GrowthRate UpdateDate
0 Brazil 785300000 15.00 2016-03
1 India 530780000 18.60 2016-08
2 United Kingdom 694582000 13.79 2016-02
3 Nigeria 130581000 14.87 2016-01
4 China 407191800 20.86 2016-09
5 Pakistan 4754000 12.54 2016-05

(i) Write the command to create the data frame from the given lists:

(ii) To display the complete data frame.

(iii) To display the column country.

(iv) To display the following columns 'Country', 'Expenditure', 'UpdateDate'.

(v) To display the first and second record.

(vi) To change the index to the column 'country'.

(vii) To display the records of 'India','United Kingdom'

(viii) To display the records of the countries whose growth rate is greater than 18.

(ix) To display the Expenditure and update data whose growth rate is greater than 18.

(x) To display the Expenditure and update data whose expenditure is 694582000.

(xi) To add the new column GDP_Growth_rate.

(xii) Write the output:

(a) data1.iloc[2:5]

(b) data1.iloc[2:5,1:2]

Answer
Output:

(xii) (a)

Country Expenditure GrowthRate UpdataDate
United Kingdom 694582000 13.79 2016-02
Nigeria 130581000 14.87 2016-01
China 407191800 20.86 2016-09

(b)

Country GrowthRate
United Kingdom 13.79
Nigeria 14.78
China 20.86
View full question & answer
Question 95 Marks
With reference to the given data frame answer the questions given below:

id name host_id host_name neighbourhood_group neighbourhood latitude longitude
0 2539 Clean & quiet apt
home by the park
2787 John Brooklyn Kensignton 40.64749 -73.97237
1 2595 Skylit Midtown
Castle
2845 Jennifer Manhattan Midtown 40.75362 -73.98377
2 3647 The Village
Of Harlem ...
New York !
4632 Elisabeth Manhattan Harlem 40.80902 -73.94190
3 3831 Cozy Entire Floor
of Brownstone
4869 LisaRoxanne Brooklyn Clinton Hill 40.68514 -73,95976
4 5022 Entire Apt:
Spacious Studio/
Loft by central park
7192 Laura Manhattan East Harlem 40.79851 -73.94399
5 5099 Large Cozy 1BR
Apartment in
Midtown East
7322 Chris Manhattan Murray Hill 40.74767 -73.97500
6 5121 BlissArtsSpace! 7356 Garon Brooklyn Bedford-Stuyvesant 40.68688 -7395596
7 5178 Large Furnished
Room Near Bway
8967 Shunichi Manhattan Hell’s Kitchen 40.76489 -73.98493

Assuming that other file is stored in CSV format named “nysc.csv” Import pandas as pd

(i) To create the Data frame of the above data.

(ii) To print the first 10 records

(iii) To display the name and Id.

Answer
Output:

View full question & answer
Question 105 Marks

Write the statements to create the Series and answer the questions below:

(a) To create 2 Lists i.e. First list is Month list which will store month name and another series day which will store the number of days in a month.

(b) To print the first 5 records from the Series.

(c) To print the last 2 records.

(d) To print the output of the commands:

(i) s2[1:]

(ii) s2[1:]

(iii) s2[::2]

(iv) s2[::-1]

(v) s2[-1]

(vi) s2['feb':'mar']

View full question & answer
5 Marks Each - Computer Science STD 12 Science Questions - Vidyadip