PYTHON Emerging Tech - AI ML Libraries MCQs

  1. Which library is primarily used for deep learning in Python?
    a) TensorFlow
    b) Pandas
    c) NumPy
    d) Matplotlib
    View Answer

    Correct answer: A — TensorFlow

  2. What will be printed?
    1 python
    2 import tensorflow as tf
    3 print(tf.__version__!="")
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  3. Which of the following is used to define tensors in TensorFlow?
    a) tf.constant()
    b) tf.Variable()
    c) tf.placeholder()
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  4. What is the output of below code?
    1 python
    2 import tensorflow as tf
    3 x = tf.constant([1,2,3])
    4 print(x.shape)
    a) (3,)
    b) (1,3)
    c) Error
    d) None
    View Answer

    Correct answer: A — (3,)

  5. Which function is used to build models in TensorFlow Keras?
    a) Sequential()
    b) Model()
    c) Layers()
    d) None
    View Answer

    Correct answer: A — Sequential()

  6. What will be printed?
    1 python
    2 from tensorflow.keras.models import Sequential
    3 print(callable(Sequential))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  7. Which of the following is used for defining layers in Keras?
    a) Dense
    b) Conv2D
    c) LSTM
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  8. What is the output of below code?
    1 python
    2 from tensorflow.keras.layers import Dense
    3 print(isinstance(Dense(10),Dense))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  9. Which library is used for tensor operations similar to NumPy but with GPU support?
    a) PyTorch
    b) TensorFlow
    c) NumPy
    d) Pandas
    View Answer

    Correct answer: A — PyTorch

  10. What will be printed?
    1 python
    2 import torch
    3 x = torch.tensor([1,2,3])
    4 print(x.size())
    a) torch.Size([3])
    b) (3,)
    c) Error
    d) None
    View Answer

    Correct answer: A — torch.Size([3])

  11. Which of the following is used for automatic differentiation in PyTorch?
    a) autograd
    b) optimizer
    c) nn
    d) None
    View Answer

    Correct answer: A — autograd

  12. What is the output of below code?
    1 python
    2 import torch
    3 x = torch.tensor(2.0,requires_grad=True)
    4 y = x**2
    5 y.backward()
    6 print(x.grad)
    a) tensor(4.)
    b) tensor(2.)
    c) Error
    d) None
    View Answer

    Correct answer: B — tensor(2.)

  13. Which of the following is PyTorch's neural network module?
    a) torch.nn
    b) torch.optim
    c) torch.autograd
    d) None
    View Answer

    Correct answer: A — torch.nn

  14. What will be printed?
    1 python
    2 import torch.nn as nn
    3 print(hasattr(nn,"Linear"))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  15. Which of the following is used for optimization in PyTorch?
    a) torch.optim
    b) torch.nn
    c) torch.autograd
    d) None
    View Answer

    Correct answer: A — torch.optim

  16. What is the output of below code?
    1 python
    2 import torch.optim as optim
    3 print(hasattr(optim,"SGD"))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  17. Which library is used for machine learning algorithms in Python?
    a) scikit-learn
    b) TensorFlow
    c) PyTorch
    d) None
    View Answer

    Correct answer: A — scikit-learn

  18. What will be printed?
    1 python
    2 import sklearn
    3 print(sklearn.__version__!="")
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  19. Which function splits dataset into train and test in scikit-learn?
    a) train_test_split()
    b) split()
    c) dataset_split()
    d) None
    View Answer

    Correct answer: A — train_test_split()

  20. What is the output of below code?
    1 python
    2 from sklearn.model_selection import train_test_split
    3 print(callable(train_test_split))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  21. Which function standardizes features in scikit learn?
    a) StandardScaler
    b) MinMaxScaler
    c) Normalizer
    d) None
    View Answer

    Correct answer: A — StandardScaler

  22. What will be printed?
    1 python
    2 from sklearn.preprocessing import StandardScaler
    3 print(callable(StandardScaler))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  23. Which function normalizes features in scikit learn?
    a) Normalizer
    b) StandardScaler
    c) MinMaxScaler
    d) None
    View Answer

    Correct answer: A — Normalizer

  24. What is the output of below code?
    1 python
    2 from sklearn.preprocessing import Normalizer
    3 print(hasattr(Normalizer(),"fit"))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  25. Which function reduces dimensionality in scikit learn?
    a) PCA
    b) LDA
    c) SVD
    d) None
    View Answer

    Correct answer: A — PCA

  26. What will be printed?
    1 python
    2 from sklearn.decomposition import PCA
    3 print(callable(PCA))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  27. Which function trains linear regression in scikit learn?
    a) LinearRegression
    b) LogisticRegression
    c) Ridge
    d) None
    View Answer

    Correct answer: A — LinearRegression

  28. What is the output of below code?
    1 python
    2 from sklearn.linear_model import LinearRegression
    3 print(hasattr(LinearRegression(),"fit"))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  29. Which function trains logistic regression in scikit learn?
    a) LogisticRegression
    b) LinearRegression
    c) Ridge
    d) None
    View Answer

    Correct answer: A — LogisticRegression

  30. What will be printed?
    1 python
    2 from sklearn.linear_model import LogisticRegression
    3 print(callable(LogisticRegression))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  31. Which function trains decision tree in scikit learn?
    a) DecisionTreeClassifier
    b) RandomForestClassifier
    c) GradientBoostingClassifier
    d) None
    View Answer

    Correct answer: A — DecisionTreeClassifier

  32. What is the output of below code?
    1 python
    2 from sklearn.tree import DecisionTreeClassifier
    3 print(hasattr(DecisionTreeClassifier(),"fit"))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  33. Which function trains random forest in scikit learn?
    a) RandomForestClassifier
    b) DecisionTreeClassifier
    c) GradientBoostingClassifier
    d) None
    View Answer

    Correct answer: A — RandomForestClassifier

  34. What will be printed?
    1 python
    2 from sklearn.ensemble import RandomForestClassifier
    3 print(callable(RandomForestClassifier))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  35. Which function trains support vector machine in scikit learn?
    a) SVC
    b) SVR
    c) LinearSVC
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  36. What is the output of below code?
    1 python
    2 from sklearn.svm import SVC
    3 print(hasattr(SVC(),"fit"))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  37. Which function trains k nearest neighbors in scikit learn?
    a) KNeighborsClassifier
    b) KNeighborsRegressor
    c) Both A and B
    d) None
    View Answer

    Correct answer: C — Both A and B

  38. What will be printed?
    1 python
    2 from sklearn.neighbors import KNeighborsClassifier
    3 print(callable(KNeighborsClassifier))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  39. Which function trains naive bayes in scikit learn?
    a) GaussianNB
    b) MultinomialNB
    c) BernoulliNB
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  40. What is the output of below code?
    1 python
    2 from sklearn.naive_bayes import GaussianNB
    3 print(hasattr(GaussianNB(),"fit"))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  41. Which function trains gradient boosting in scikit learn?
    a) GradientBoostingClassifier
    b) GradientBoostingRegressor
    c) Both A and B
    d) None
    View Answer

    Correct answer: C — Both A and B

  42. What will be printed?
    1 python
    2 from sklearn.ensemble import GradientBoostingClassifier
    3 print(callable(GradientBoostingClassifier))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  43. Which function evaluates model accuracy in scikit learn?
    a) accuracy_score
    b) precision_score
    c) recall_score
    d) None
    View Answer

    Correct answer: A — accuracy_score

  44. What is the output of below code?
    1 python
    2 from sklearn.metrics import accuracy_score
    3 print(accuracy_score([1,0],[1,0]))
    a) 1.0
    b) 0.0
    c) Error
    d) None
    View Answer

    Correct answer: A — 1.0

  45. Which function evaluates confusion matrix in scikit learn?
    a) confusion_matrix
    b) classification_report
    c) metrics_matrix
    d) None
    View Answer

    Correct answer: A — confusion_matrix

  46. What will be printed?
    1 python
    2 from sklearn.metrics import confusion_matrix
    3 print(confusion_matrix([1,0],[1,0]))
    a) [[1 0] [0 1]]
    b) [[0 1] [1 0]]
    c) Error
    d) None
    View Answer

    Correct answer: A — [[1 0] [0 1]]

  47. Which function evaluates classification report in scikit learn?
    a) classification_report
    b) confusion_matrix
    c) report()
    d) None
    View Answer

    Correct answer: A — classification_report

  48. What is the output of below code?
    1 python
    2 from sklearn.metrics import classification_report
    3 print("precision" in classification_report([1,0],[1,0]))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  49. Which function saves model in scikit learn?
    a) joblib.dump()
    b) pickle.dump()
    c) save()
    d) None
    View Answer

    Correct answer: A — joblib.dump()

  50. What will be printed?
    1 python
    2 import joblib
    3 print(callable(joblib.dump))
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

Quick Links to Explore