0% found this document useful (0 votes)
36 views7 pages

AICTE QIP PG Certification: Python & AI

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)
36 views7 pages

AICTE QIP PG Certification: Python & AI

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

AICTE QIP PG Certification Program

AI and its Application , IIIT Lucknow


Submitted by- Avinash Kumar, [Link]. 08 , ID(QIPFPG25000040)

Section A: Very Short Answer Type Questions


(Total: 15 Marks)
Answer all questions. Each answer should not exceed 40 words
Q.1. Name two popular Python Integrated Development Environments (IDEs).

Answer: PyCharm and Jupyter Notebook.

Q.2. What is the key difference between a ‘list’ and a ‘tuple’?

Answer: List is mutable (can change), Tuple is immutable (cannot change).

Q.3. Which loop is preferable when iterations are known: ‘for’ or ‘while’?

Answer: The 'for' loop is preferable.

Q.4. What does the ‘open()’ function return in read mode (‘r’)?

Answer: It returns a file object.

Q.5. What is the output of the string slice ‘Hello[1:4]’?

Answer: It gives 'ell'.

Q.6. Which Python library is essential for data manipulation?

Answer: Pandas.

Q.7. Define an ‘Agent’ in Artificial Intelligence.

Answer: An agent is an entity that perceives its environment and acts on it.

Q.8. What does the acronym PEAS stand for?

Answer: Performance, Environment, Actuators, Sensors.

Q.9. Differentiate Supervised and Unsupervised Learning in one point.

Answer: Supervised uses labeled data, Unsupervised uses unlabeled data.

Q.10. Which search algorithm uses path cost and a heuristic?

Answer: A* Search Algorithm.


Q.11. Is Linear Regression for classification or regression?

Answer: It is used for regression.

Q.12. State the primary objective of K-means clustering.

Answer: To group data into K clusters based on similarity.

Q.13. Name the technique for reducing dataset variables.

Answer: Dimensionality Reduction (e.g., PCA).

Q.14. What is the common learning rule for training ANNs?

Answer: Backpropagation.

Q.15. Which NN is best for image processing?

Answer: Convolutional Neural Network (CNN).

Section B: Short Answer Type Questions

Q.16. Differentiate between actual and formal arguments in a Python function with
a code example.

Answer: In Python, actual arguments are the values passed to a function when it is called,
whereas formal arguments are the variables defined in the function definition that receive
those values.

Example:
def add(a, b): # 'a' and 'b' are formal arguments
return a + b

result = add(5, 10) # 5 and 10 are actual arguments

Here, 5 and 10 are actual arguments, and 'a' and 'b' are formal arguments.

Q.17. Explain the use of ‘os’ and ‘sys’ modules. Write code to list files in a directory.

Answer: The 'os' module provides functions to interact with the operating system like file
handling, directory management, etc. The 'sys' module provides access to system-specific
parameters and functions, such as command line arguments and Python interpreter
controls.

Example code to list files in a directory: import os


files = [Link]('.')
print(files)

Q.19. Describe Boolean logic and write the truth table for the ‘AND’ operator.

Answer: Boolean logic is a form of algebra in which all values are either True or False. It
forms the basis of logic gates in computing. The AND operator returns True only if both
operands are True.

Truth Table (AND):


A B A AND B
0 0 0
0 1 0
1 0 0
1 1 1

Q.21. (10 Marks)

(a)
A Python dictionary is a built-in data structure that stores data in the form of key-value
pairs. It allows quick retrieval of values using unique keys. Dictionaries are unordered,
mutable, and indexed by keys, whereas lists are ordered collections accessed by
numerical indices.

Difference:
• List: Ordered, indexed numerically, allows duplicates.

• Dictionary: Unordered, indexed by unique keys, stores mappings.

Example: A student record can be stored as follows:

student = {
'Name': 'Alice',
'Roll No': 101,
'Class': '10th',
'Marks': 89
}

(b)
Program to read a text file, count word frequency, and write results to a CSV file. This is
useful in Natural Language Processing (NLP), for example, analyzing the frequency of
words in a document.
import csv
from collections import Counter

with open('[Link]', 'r') as f:


words = [Link]().split()

freq = Counter(words)

with open('word_count.csv', 'w', newline='') as f:


writer = [Link](f)
[Link](['Word', 'Frequency'])
for word, count in [Link]():
[Link]([word, count])

Fig: Example Word Frequency Visualization

Q.22. (10 Marks)

(a)
The K-Nearest Neighbors (KNN) algorithm is a supervised learning technique used for
both classification and regression. It predicts the class of a data point by looking at the 'K'
closest labeled points in the feature space. Distance is usually calculated using Euclidean,
Manhattan, or Minkowski distance.

Effect of 'K':

• Small K (e.g., K=1): Model becomes very sensitive to noise (overfitting).


• Large K: Model becomes smoother and less sensitive to noise but may underfit.
Choosing the right K is crucial and often done using cross-validation.
(b)
The A* search algorithm is a graph traversal and pathfinding algorithm widely used in AI
for games, robotics, and route planning. It uses a cost function:
f(n) = g(n) + h(n)
where:
• g(n): Cost from start node to current node
• h(n): Heuristic (estimated cost from current node to goal)

Why complete? A* will always find a solution if one exists.


Why optimal? If the heuristic h(n) is admissible (never overestimates), then A*
guarantees the shortest/least-cost path.

Example: In a grid maze, A* can find the shortest path using Manhattan distance as
heuristic.

Section D: Application & Case Study Based Questions

Q.24. (25 Marks) The Data Analyst


(a) Python code using Pandas:

import pandas as pd
import [Link] as plt

df = pd.read_csv('sales_data.csv')
print([Link]())
print([Link]())

total_sales = [Link]('Product Category')['Sales Amount'].sum()


west_sales = df[(df['Region']=='West') & (df['Sales Amount']>1000)]

print(total_sales)
print(west_sales)

(b) Visualizations: A bar chart and pie chart help interpret data trends.

Findings: The bar chart shows which region has the highest sales (West). The pie chart
reveals category contribution—Electronics dominates, followed by Groceries and
Clothing.

Q.25. (25 Marks) The Machine Learning Engineer


(a) Choice of algorithms:

For predicting loan default, I choose:


• KNN: Works well for smaller datasets and is easy to interpret.
• Decision Tree: Handles mixed data types (categorical/numerical) and provides
interpretable rules.

(b) Concept explanation:

Decision Tree works by splitting the dataset into subsets based on feature values. It uses
metrics like Gini Index or Information Gain to decide the best splits. For example, 'credit
score' may be the root node, splitting applicants into high vs low risk.

(c) Evaluation measures:

• Precision: Accuracy of positive predictions (important to avoid false defaults).


• Recall: Ability to capture actual defaulters (important to minimize bank losses).
• F1-Score: Balance between precision and recall.
Accuracy alone is insufficient because if most applicants do not default, a model
predicting 'No Default' always would give high accuracy but be useless.

• These anomalies can be flagged and removed.


Alternatively, clustering (e.g., K-Means) can group similar fruits; rotten ones appear as
outliers.

Common questions

Powered by AI

Python dictionaries provide quick retrieval of values using unique keys, unlike lists that use numerical indices. Dictionaries are unordered and mutable, allowing efficient mappings, whereas lists are ordered and allow duplicates. This makes dictionaries ideal for storing key-value pairs like a student record.

Boolean logic underpins modern computing by using logical operators like AND, OR, and NOT, which form the foundation for logic gates. These gates perform basic logical functions that combine to execute complex computations in digital circuits.

A heuristic estimates the cost from the current node to the goal in search algorithms, guiding the path selection. In the A* algorithm, an admissible heuristic ensures optimal path-finding by not overestimating, maintaining the balance between search accuracy and cost.

Dimensionality reduction simplifies datasets by reducing the number of variables through techniques like PCA, enhancing computational efficiency and mitigating risks of overfitting. It helps in visualizing high-dimensional data by capturing the most informative parts.

K-Nearest Neighbors handles overfitting with a small K value, where the model becomes too sensitive to noise. Conversely, a large K may cause underfitting as the model becomes smoother. Choosing the right K is crucial for model accuracy, typically determined via cross-validation.

The os module aids in interacting with the operating system for tasks like file handling and directory management, while the sys module provides system-specific parameters and functions. Together, they enable tasks like listing files in a directory, as shown in the code: import os; files = os.listdir('.'); print(files)

Pandas is essential for data manipulation in Python as it provides powerful data structures like DataFrames and Series. These structures simplify complex data operations, enabling efficient data cleaning, merging, aggregation, and exploration.

When using K-Means clustering, considerations include selecting the correct number of clusters (K), which impacts group similarity, and handling outliers that can skew results. K should be chosen based on data exploration or methods like the elbow method.

The A* search algorithm guarantees optimality and completeness by using a cost function f(n) = g(n) + h(n), where g(n) is the cost from the start node and h(n) is an admissible heuristic. If h(n) never overestimates, A* finds the shortest path when a solution exists.

Challenges in predicting loan defaults include handling imbalanced datasets, where non-default cases dominate, and selecting appropriate evaluation metrics like precision, recall, and F1-score, beyond accuracy, to ensure reliable predictions. These can be addressed by using algorithms like Decision Trees and KNN, which handle mixed data types.

You might also like