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

New Microsoft Word Document

Uploaded by

purushothama1970
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

New Microsoft Word Document

Uploaded by

purushothama1970
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

1.

Set 1: Beginner Level

1. Which operator is used for adding two numbers in Python?

o (a) + (Correct)

2. What is the output of print("Hello" + " world!")?

o (a) "Hello world!" (Correct)

3. Which data type is used to store text in Python?

o (c) String (Correct)

4. What is the type of data it is going to be A data which has been taken
with the help of an input function?

o Input data is of type string.

5. What is the correct way to create a variable in Python?

o (a) var_name = value (Correct)

6. What is the purpose of # This is a comment?

o (b) To be ignored by the Python interpreter (Correct)

7. What is the output of print(2 ** 3)?

o (c) 8 (Correct)

8. What is the difference between a list and a dictionary?

o (c) Both are mutable. (Correct)

9. What is the correct way to create a list?

o (b) list = [1, 2, 3] (Correct)

10. What is the output of print(len([1, 2, 3]))?

o (c) 3 (Correct)

11. What is the correct way to access the second element of a list?

o (a) list[1] (Correct)

2. Set 2: Intermediate Level

1. What is the difference between == and is operators?

o == checks for equality of value, whereas is checks for identity (whether


both operands refer to the same object).
2

2. What is a loop in Python and how is it used?

o A loop is a control flow statement that allows code to be executed


repeatedly based on a condition. Common loops are for and while.

3. Explain the difference between conditional statements like if and else.

o if is used to execute code if a condition is true. else is used to execute


code if the condition is false.

4. What are functions in Python and how are they defined?

o Functions are blocks of reusable code that perform a specific task.


They are defined using the def keyword.

5. What are modules and packages in Python and how are they imported?

o Modules are files containing Python code. Packages are directories of


modules. They are imported using the import statement.

6. Explain the concept of indexing and slicing in lists.

o Indexing refers to accessing elements by their position. Slicing allows


accessing a range of elements.

7. Describe how dictionaries work and how to access elements within


them.

o Dictionaries store data in key-value pairs. Elements are accessed


using their keys.

8. What is the purpose of comments in Python code?

o Comments are used to explain code and are ignored by the interpreter.

9. How can you handle errors using try and except blocks?

o Errors are handled by wrapping code in try block and catching


exceptions with except.

10. What are some basic string manipulation techniques in Python?

o Concatenation, slicing, case conversion, and finding substrings.

11. Explain slicing of a string and how slicing can be used to reverse a
string give examples.

o Slicing extracts parts of a string using string[start:end:step]. To reverse:


string[::-1].

12. Which data types does Python support?


3

o (c) Integers, floats, strings, Booleans, lists, tuples, dictionaries


(Correct)

13. What is the output of print(2 + 3 * 4)?

o (b) 14 (Correct)

14. Which of these is a valid operator for dividing two numbers without
remainder?

o (a) / (Correct)

15. What is the output of print(4 ** 2)?

o (c) 16 (Correct)

16. What is the difference between a list and a tuple in Python?

o (b) Lists are mutable, tuples are immutable (Correct)

17. What is the correct way to create a list?

o (b) list = [1, 2, 3] (Correct)

18. What is the output of print(len([1, 2, 3]))?

o (c) 3 (Correct)

19. What is the correct way to access the third element of a list?

o (a) list[2] (Correct)

20. What is the output of print(x in [1, 2, 3]) for x = 2?

o (a) True (Correct)

21. What is a dictionary in Python?

o (a) A collection of key-value pairs (Correct)

22. What is the correct way to create a dictionary?

o **

3. (a) dict = {"name": "John", "age": 30}** (Correct)

23. What is the output of print(my_dict["name"]) for my_dict = {"name":


"John", "age": 30}?

o "John" (Correct)

24. What is the difference between break and continue in a loop?


4

o break exits the loop, while continue skips to the next iteration.

25. Explain the behavior of the else block in a try/except statement.

o The else block is executed if the try block does not raise an exception.

26. Explain the concept of object-oriented programming in Python.

o Object-oriented programming (OOP) is a paradigm based on objects


containing both data and methods. It uses classes to define objects.

27. What does KNN stand for?

o (c) K-Nearest Neighbors (Correct)

28. What is the basic idea behind KNN?

o (a) It predicts the value of a new data point based on the most
similar data points in the training data (Correct)

29. What is the role of "K" in KNN?

o (d) It defines the number of nearest neighbors considered for


prediction (Correct)

30. What type of learning is KNN?

o (a) Supervised learning (Correct)

31. What type of data is KNN best suited for?

o (d) All of the above (with caveats) (Correct)

32. What are some advantages of KNN?

o (d) All of the above (Correct)

33. What are some disadvantages of KNN?

o (d) All of the above (Correct)

34. How does KNN choose the distance metric?

o (b) The user needs to specify it based on the data (Correct)

35. What happens if two or more neighbors have the same closest
distance?

o (c) The most common class among those neighbors is chosen


(Correct)

36. Can KNN be used for regression tasks?


5

o (b) Yes, by predicting the average value of the neighbors (Correct)

37. What are some applications of KNN?

o (d) All of the above (Correct)

38. What are some alternatives to KNN?

o (d) All of the above (Correct)

39. How can you improve the performance of KNN?

o (d) All of the above (Correct)

40. What are the biggest strengths of KNN compared to other machine
learning algorithms in your opinion? How would you explain them to
someone new to the field?

o KNN is simple to understand and implement, does not make strong


assumptions about the data, and works well with multi-class problems.
It can be easily explained as finding the "nearest neighbors" to make a
prediction based on similarity.

41. Do you think KNN's sensitivity to noisy data is a major limitation? Would
you consider it a dealbreaker for using KNN in a specific project? Why
or why not?

o KNN's sensitivity to noisy data can be a limitation as it can lead to


incorrect predictions. However, it may not be a dealbreaker if
appropriate preprocessing and feature selection techniques are applied
to minimize noise.

42. How much do you believe "curse of dimensionality" affects KNN's


performance in practice? What strategies could you employ to mitigate
this issue?

o The "curse of dimensionality" significantly affects KNN's performance


by increasing the computational complexity and reducing the accuracy.
Dimensionality reduction techniques like PCA or feature selection can
mitigate this issue.

43. Explain the process of data preprocessing.

o Data preprocessing involves cleaning data (handling missing values,


removing outliers), transforming data (normalization, scaling), and
reducing data (feature selection, extraction) to prepare it for analysis.

44. Explain Turing test.

o The Turing Test, proposed by Alan Turing, assesses a machine's


ability to exhibit intelligent behavior indistinguishable from a human.
6

45. Who coined the term AI at the AI conference at Dartmouth College?

o John McCarthy coined the term "Artificial Intelligence."

46. Explain the possible drawbacks of using AI.

o Drawbacks include ethical concerns, job displacement, data privacy


issues, and the potential for biased decision-making.

47. Explain the categorization of AI models based on their capabilities.

o AI models can be categorized into:

 Narrow AI: Specialized tasks (e.g., virtual assistants).

 General AI: Broad tasks similar to human intelligence (still


theoretical).

 Super AI: Superior intelligence surpassing human abilities


(speculative).

48. With examples, explain the difference between supervised learning and
unsupervised learning.

o Supervised learning uses labeled data for training (e.g., classification,


regression). Unsupervised learning uses unlabeled data to find
patterns (e.g., clustering, dimensionality reduction).

49. How is k determined in KNN and what is distance-weighted nearest


neighbors?

o "k" is determined by cross-validation to balance bias-variance tradeoff.


Distance-weighted nearest neighbors assign weights to neighbors
based on their distance, giving closer neighbors more influence.

50. Give out pros and cons of KNN.

o Pros: Simple, no training phase, effective with small datasets. Cons:


Computationally expensive with large datasets, sensitive to noise and
irrelevant features.

51. What are support vectors and explain SVM?

o Support vectors are data points that define the decision boundary in
SVM (Support Vector Machine), a supervised learning model used for
classification and regression.

4. 52

2. Explain accuracy, error, false alarm, precision, recall, and miss with
examples.
7

o Accuracy: Proportion of true results (both true positives and true


negatives) in the dataset. Example: In a dataset with 100 samples, if
the model correctly predicts 90, the accuracy is 90%.

o Error: The rate of incorrect predictions. Example: If 10 out of 100


predictions are wrong, the error rate is 10%.

o False Alarm (False Positive): Incorrectly identifying a negative


instance as positive. Example: Predicting spam for a non-spam email.

o Precision: The proportion of true positives out of all positive


predictions. Example: If the model predicts 50 emails as spam, but only
40 are actually spam, precision is 80%.

o Recall (Sensitivity): The proportion of true positives out of actual


positives. Example: If there are 50 spam emails and the model
identifies 40, recall is 80%.

o Miss (False Negative): Incorrectly identifying a positive instance as


negative. Example: Not identifying an actual spam email as spam.

3. Explain softmax activation function and cost function.

o Softmax Activation Function: Converts logits (raw predictions) into


probabilities that sum to 1, used in multi-class classification. Example:
For logits [2.0, 1.0, 0.1], the softmax probabilities are [0.7, 0.2, 0.1].

o Cost Function: Measures the difference between predicted and actual


values to optimize the model. Common types include Mean Squared
Error (MSE) for regression and Cross-Entropy Loss for classification.
Example: Cross-Entropy Loss for binary classification:
−1N∑i=1N[yilog⁡(pi)+(1−yi)log⁡(1−pi)]-\frac{1}{N} \sum_{i=1}^{N} [y_i \
log(p_i) + (1-y_i) \log(1-p_i)]−N1∑i=1N[yilog(pi)+(1−yi)log(1−pi)]

4. What will happen to training error if k is varied from 1 to infinity?

o As kkk increases from 1 to infinity:

 For k=1k = 1k=1, the training error is typically low because the
model is likely to overfit.

 As kkk increases, the training error generally increases because


the model becomes less sensitive to individual data points.

 For kkk approaching the size of the training dataset, the model
will predict the majority class for all inputs, resulting in higher
training error.

5. Explain how the generalization error (e.g., holding out some data for
testing) would change when k varies?

o Generalization Error: Reflects model performance on unseen data.


8

 For small kkk, the model may overfit, leading to high


generalization error.

 An optimal kkk balances bias and variance, minimizing


generalization error.

 For very large kkk, the model may underfit, leading to high
generalization error due to high bias.

6. Why may K-NN be undesirable when the input dimension is high? Cost,
curse.

o Curse of Dimensionality: In high-dimensional spaces, distances


between data points become less meaningful, and the volume of space
increases exponentially, making it hard for K-NN to find nearest
neighbors effectively.

o Cost: High computational cost as K-NN requires computing distances


to all training samples for each prediction.

7. Advantages and disadvantages of SVM kernel trick.

o Advantages:

 Allows handling non-linear relationships by transforming input


space to higher dimensions.

 Can improve classification performance with appropriate kernels


(e.g., RBF, polynomial).

o Disadvantages:

 Computationally intensive for large datasets.

 Choice of kernel and hyperparameters is critical and can be


complex.

8. How can we prevent overfitting in CNN?

o Techniques include:

 Dropout: Randomly dropping units during training to prevent co-


adaptation.

 Data Augmentation: Creating variations of training data (e.g.,


rotations, flips) to increase dataset size.

 Regularization: Adding penalty terms (e.g., L2 regularization) to


the loss function to constrain model complexity.

 Early Stopping: Monitoring validation performance and


stopping training when performance degrades.
9

9. Can SVMs be used for regression problems?

o Yes, SVMs can be used for regression tasks using Support Vector
Regression (SVR), which aims to find a function within a specified
margin that fits the training data.

You might also like