AIYA Pre-Requisite Session 2
AIYA Pre-Requisite Session 2
Pre-Requisites
Module 1 – Introduction to Python
Importance of Python in AI
Python's pivotal role in Artificial Intelligence (AI) stems from its versatility, simplicity, and
rich library ecosystem. With a clean syntax and readability, Python facilitates the
development of concise AI code, crucial for complex algorithms. Its widespread use,
supported by libraries like NumPy and scikit-learn, fosters collaborative innovation, while
compatibility with frameworks such as TensorFlow enhances seamless integration,
affirming Python's effectiveness in unlocking AI's full potential.
Reading Material:
Problem 1:
List Operations –
Create a Python script that:
1. Initializes a list of numbers
2. Sorts the list in ascending order
3. Finds the maximum and minimum values in the list
4. Calculates the sum and average of all the numbers in the list
Problem 2:
Tuple Manipulation –
Write a Python script that:
1. Defines a tuple containing the days of the week
2. Asks the user to input a number representing a day (e.g., 1 for Monday, 2 for
Tuesday, and so on)
3. Displays the corresponding day of the week based on the user's input
Assignment 2:
Problem 1:
Dictionary Operations –
1. Develop a Python script that:
2. Creates a dictionary storing student names as keys and their ages as values
3. Provides functionality to:
- Add a new student to the dictionary
- Update the age of an existing student
- Remove a student from the dictionary based on the user's input (student's name)
- Displays the total count of students in the dictionary
Problem 2:
Array Manipulation –
Build a Python script that:
1. Creates an array (using the array module or Python list) containing a sequence of
numbers.
2. Prompts the user to enter a number
3. Searches for the entered number in the array and displays whether it exists in the
array or not. If present, also show its index
Variables store data. They can hold different types like integers, floats, or strings.
Python
Variable Stored Data
age = 25
name = “John”
Code Output
def greet(name): Hello, Alice!
return "Hello, " + name + "!"
print(greet("Alice"))
Modules are files containing Python code that can be reused
Code Output
# In a separate file named utils.py 12
def multiply(x, y):
return x * y