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

Data_Science_Sample_Paper_Deewan[1]

The document is a sample paper containing multiple-choice questions related to Python programming, data manipulation with Pandas, and machine learning concepts. Each question provides four answer options, testing knowledge on topics such as loop behavior, DataFrame operations, confusion matrices, and code outputs. The questions cover a range of fundamental programming and data science concepts suitable for assessing understanding in these areas.

Uploaded by

ujjwalsingh6396
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Data_Science_Sample_Paper_Deewan[1]

The document is a sample paper containing multiple-choice questions related to Python programming, data manipulation with Pandas, and machine learning concepts. Each question provides four answer options, testing knowledge on topics such as loop behavior, DataFrame operations, confusion matrices, and code outputs. The questions cover a range of fundamental programming and data science concepts suitable for assessing understanding in these areas.

Uploaded by

ujjwalsingh6396
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Sample Paper

1. *What is the output of the following code?*

python

for i in range(3):

print(i, end=" ")

- a) 1 2 3

- b) 0 1 2

- c) 0 1 2 3

- d) 1 2

2. *What does the else block in a loop do in Python?*

- a) Executes if the loop encounters break.

- b) Executes when the loop is skipped.

- c) Executes only if the loop completes all iterations.

- d) Executes before the loop starts.

3. *How can you display the first five rows of a DataFrame named df?*

- a) df.show()

- b) df.first()

- c) df.head()

- d) df.top(5)

4. *Which of the following is the correct syntax to calculate the mean of a


column named salary in Pandas?*

- a) df.mean('salary')

- b) df.salary.mean()

- c) df['mean'].salary()
- d) df['salary'].average()

5. *Which method is used to read a file line by line in Python?*

- a) readlines()

- b) readline()

- c) read()

- d) iterlines()

6. *What happens if you try to open a file that doesn’t exist in 'r' mode?*

- a) It creates a new file.

- b) It raises a FileNotFoundError.

- c) It opens the file with an empty content.

- d) None of the above.

7. *What is the primary purpose of K-Fold Cross-Validation?*

- a) To reduce overfitting

- b) To increase training accuracy

- c) To evaluate model performance

- d) To avoid underfitting

8. *Which of the following is not part of a confusion matrix?*

- a) True Positives (TP)

- b) False Positives (FP)

- c) True Negatives (TN)

- d) Loss Function
9. *What does the False Negative (FN) value represent in a confusion
matrix?*

- a) Predicted negative but is actually positive

- b) Predicted positive but is actually negative

- c) Both predicted and actual positive

- d) None of the above

10. *What is the main assumption of Linear Regression?*

- a) Data should be normally distributed

- b) Relationship between dependent and independent variables is


linear

- c) There should be no multicollinearity

- d) All of the above

11. *Which of the following criteria is used to split nodes in a decision


tree?*

- a) Entropy

- b) Gini Index

- c) Both a and b

- d) Gradient Boosting

12. *Random Forest is an example of which type of ensemble method?*

- a) Bagging

- b) Boosting

- c) Stacking

- d) Averaging

13. *Which of the following is a boosting algorithm?*

- a) Random Forest

- b) AdaBoost

- c) K-Means
- d) KNN

14.What will be the output of the following control structure?


n=3
if n == 2:
print("Hello")
elif n == 3:
print("World")
else:
print("Nothing")

- a) n is assigned to 2

- b) The string "Hello" is printed to the standard out

- c) The string "World" is printed to the standard out

- d) The string "Nothing" is printed to the standard out

15. What is the output of the below program?


>>> word = 'abcdefghij'
>>> word[:3] + word[3:]

- a) abcdefg

- b) abcabc

- c) abcdefghij

- d) abchij

16. What is the output:


>>> print 0xA + 0xB + 0xC

- a) 0xA0xB0xC

- b) Error

- c) 0x22

- d) 33
17. What is the output of the below program?
logfile = open('test.log', 'w')
logfile.write('test succeeded')
logfile.close()
print file('test.log').read()

- a) File error

- b) test succeeded

- c) open error

- d) unknown result

18. What is the output of below program?

def writer():
title = 'Sir'
name = (lambda x:title + ' ' + x)
return name

who = writer()
who('Arthur')

- a) Arthur Sir

- b) Arthur

- c) Sir Arthur

- d) None of the mentioned

19. What is the output of the following code?

def foo(x):
x[0] = ['def']
x[1] = ['abc']
return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))

- a) True

- b) False

- c) None

- d) Error

20. What is the output when following code is executed?

>>>names = ['Amir', 'Bear', 'Charlton', 'Daman']


>>>print names[-1][-1]

- a) A

- b) Daman

- c) Error

- d) n

21. What will be the output?

>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]

- a) [2, 3, 9]

- b) [1, 2, 4, 3, 8, 9]

- c) [1, 4, 8]

- d) (1, 4, 8)

22 What is the result of this code?

a=[1,2,3,4,5,6,7,8,9]
a[::2]

- a) [1,3,5,7,9]

- b) Syntax Error
- c) [1,2]

- d) [1,3]

23. What is the type of b?

a = "bay"
b = a[0]

- a) chr

- b) list

- c) odr

- d) str

You might also like