Python with AI
Objective Questions (MCQ)
1. Which Python library is mainly used for numerical computing?
A. Pandas
B. NumPy
C. Matplotlib
D. Jupyter Notebook
2. Tuples in Python are ______.
A. Mutable
B. Unordered
C. Ordered and unchangeable
D. Changeable
3. What is the file extension for Jupyter Notebook files?
A. .pynb
B. .ipy
C. .notebook
D. .ipynb
4. Which library is commonly used for data visualization?
A. NumPy
B. Pandas
C. Matplotlib
D. IPython
5. Machine Learning is a field that combines statistics, AI, and _____.
A. Physics
B. Computer Science
C. Biology
D. Chemistry
6. Supervised learning requires ________.
A. Only unlabeled data
B. No training data
Python with AI
C. Labeled input and output
D. Random data
7. Which of the following is an example of a supervised learning task?
A. Clustering
B. Regression
C. Association mining
D. Dimensionality reduction
8. Unsupervised learning finds patterns in ________.
A. Labeled data
B. Structured output
C. Unlabeled data
D. Selected variables
9. Which scikit-learn module handles model selection?
A. preprocessing
B. metrics
C. datasets
D. model_selection
10. The NumPy ndarray requires all elements to be ______.
A. Different types
B. Same type
C. Strings only
D. Integer only
11. Jupyter Notebook allows writing code, visualizing data, and _____.
A. Creating video files
B. Writing Markdown text
C. Running only C++ code
D. Creating SQL databases
12. Pandas is mainly used for:
A. Graphical animation
B. Web development
C. Working with structured/tabular data
D. Audio processing
Python with AI
13. In NumPy, slicing arr[5:8] means _______.
A. Replace index 5
B. Retrieve values not including 8
C. Delete values
D. Return all odd numbers
14. Which learning type uses rewards and penalties?
A. Supervised
B. Semi-supervised
C. Reinforcement
D. Unsupervised
15. Which algorithm category includes K-Means?
A. Regression
B. Clustering
C. Classification
D. Association
16. Scikit-learn relies heavily on which base package?
A. JSON
B. NumPy
C. OS
D. CSV
17. Matplotlib is commonly imported with the alias ______.
A. mpl
B. mat
C. plt
D. graph
18. Which dataset in mglearn is used for two-class classification examples?
A. wave
B. iris
C. forge
D. random
19. What is the main purpose of regression?
Python with AI
A. Grouping items
B. Predicting continuous values
C. Splitting dataset
D. Assigning labels
20. Which feature of Jupyter Notebook makes it useful for data science?
A. Building Android apps
B. Interactive execution of code
C. Compiling C programs
D. Sending emails
Python with AI
SECTION B: SUBJECTIVE QUESTIONS
1. You are given a list of daily temperatures stored in a Python list. Explain how you would
use NumPy to calculate the average temperature more efficiently compared to using
normal Python lists.
You would convert the Python list to a NumPy array and use the built-in
NumPy function, such as .mean(), which is optimized for numerical operations
on arrays
2. A dataset contains customer age, income, and purchase history. Describe two steps you
would take to clean this dataset before using it for machine learning
Two cleaning steps would be handling missing values and checking
for and addressing outliers
Python with AI
3. Explain the difference between classification and regression in machine learning.
Provide one example for each type.
Classification predicts a discrete label , while regression predicts a continuous value.
4. You want to plot a line graph showing how a student's score improves over 10 weeks.
Describe the steps you would take using Matplotlib (no need to write full code).
The steps involve importing Matplotlib with plt, defining the weekly data (weeks and scores) as
arrays, and then using [Link]() and [Link]().
Python with AI
5. Jupyter Notebook allows code execution in separate cells. Explain one advantage of this
feature when working on data science or AI projects.
The cell-based execution allows for interactive and incremental development and debugging, letting
you run small parts of code and immediately see results.