For Studnets Updated Labmanual after approval
For Studnets Updated Labmanual after approval
Aim:
To build a simple AI model using python for Maze problem
Algorithm:
Step1: Initialize BFS
Aim:
To calculate the required cement, sand, and aggregate for a concrete mix (1:2:4).
Algorithm:
1. Input cement quantity
2. Compute sand and aggregate using the ratio 1:2:4
3. Display the required quantities
Ex.No: 3 LED RESISTOR CALCULATOR
Date:
Aim:
To calculate the required resistor value for an LED circuit using: R = (Vs - Vled) / Iled
Algorithm:
1. Input supply voltage (Vs)
2. Input LED voltage (Vled)
3. Input LED current (Iled)
4. Compute resistor value using R = (Vs - Vled) / Iled
5. Display the resistor value (R) in ohms
Aim:
To convert Voltage-Current to Power Conversion
Algorithm:
Aim:
To calculate stress, strain, and Young’s modulus using Hooke’s law.
Algorithm:
1. Get the applied force (F), original area (A), original length (L), and elongation (ΔL).
Aim:
To determine the grade of a student based on their marks using if-else statements.
Algorithm:
1. Input the marks M.
2. Use an if-elif-else ladder to check the grade range.
3. Print the grade based on the marks.
Aim:
To check if the entered character is an alphabet or a digit using an if-else statement.
Algorithm:
1. Input the character C.
2. Use an if statement to check if the character is alphabetic.
3. Use an elif statement to check if the character is a digit.
4. Print the appropriate message based on the check.
Aim:
To calculate the sum of digits in a number.
Algorithm:
1. Initialize sum_digits to 0
2. While the number is greater than 0:
o Extract the last digit using number % 10
o Add the extracted digit to sum_digits
o Remove the last digit using number //= 10
3. Print the sum of digits
Algorithm:
1. Input the number N.
2. Initialize a variable 'factorial' to 1.
3. Use a 'for' loop to multiply the factorial with each number from 1 to N.
4. Print the factorial.
Date:
Aim:
To create a function that calculates the GPA for the first semester results based on the grades
and credit hours of the courses.
Algorithm:
Aim
To use recursive function to calculate GCD of two numbers using python
Algorithm
4. Return the first number which is the GCD of the two numbers.
5. Print the GCD.
Aim:
Algorithm:
1. use *args. It enables to accept more arguments than the number of formal arguments
previously defined.
2. use **kwargs to pass a keyworded, variable-length argument list.kwargs is called
with a double star. The reason for this is that the double star permits to pass over
keyword arguments (in any order). Arguments are collected into a dictionary within
the function that allow us to access them by their keys.
To write a Python code to check if a number is positive, negative, or zero using lamda
functions.
Algorithm:
Aim:
To write a Python program to find the sum of natural numbers using recursive function.
Algorithm:
Aim:
To write a Python program to display the Fibonacci sequence using recursive function.
Alogrithm:
Aim:
Algorithm:
Date:
Aim:
Algorithm:
Date:
Aim:
To replace the last value of a tuple with a new value and find the duplicates in a tuple.
Algorithm:
Anaconda is a distribution that includes Python, R, Jupyter Notebook, and data science
libraries.
Jupyter Notebook is a web-based interactive environment for writing Python and R code.
1. Print a Message
a = 10
b=5
sum = a + b
sum
3. Data handling
Import Libraries
import pandas as pd
import numpy as np
import pandas as pd
print("DataFrame:\n", df)
# Access a column
df['Experience'] = [2, 5, 7]
# Save to CSV
df.to_csv('data.csv', index=False)
Result:
Thus the Anaconda was downloaded, Installed, and Explored using R/Python for Data
Analytics
Ex No: 20 CREATION OF NUMPY ARRAY
Date:
Aim:
To create a NumPy array using a tuple and determine its size, shape, and dimension.
Algorithm:
Aim:
To manipulate array attributes such as shape, size, dimension, dtype, itemsize, and perform
reshaping, transposition, flattening, and data type conversion using NumPy.
Algorithm:
Aim:
To create subarrays using NumPy
Algorithm:
Aim:
To perform the reshaping of the array along the row vector and column vector
Algorithm:
2. Use the NumPy reshape() function to reshape the array into a column vector. This
means converting it to a 2D array with n rows and 1 column (i.e., shape (n, 1)).
4. Output:
Aim:
To concatenate two arrays using NumPy
Algorithm:
1. Input two NumPy arrays arr1 and arr2 of size n and m respectively.
1. Initialization:
o Define two arrays arr1 and arr2 with their respective values.
3. Concatenate Arrays:
o Use NumPy's concatenate() function to combine the arrays along a specified
axis.
For 1D arrays, concatenate along the horizontal axis (axis=0).
For 2D arrays, concatenate along either:
Rows (axis=0): concatenated_array = np.concatenate((arr1,
arr2), axis=0)
Columns (axis=1): concatenated_array = np.concatenate((arr1,
arr2), axis=1)
5. Output:
A new array, concatenated_array, which is the result of joining arr1 and arr2.
Ex No: 25 STATISTICAL OPERATIONS ON DATA
Date:
Aim:
To perform statistical operations on data using NumPy and Pandas
Algorithm:
Aim:
To write python code to illustrate creation of series and data frames in Pandas.
Algorithm:
1. Initialize DataFrame:
o Create a DataFrame from a dataset that may contain missing values (NaN or
None).
2. Check for Missing Data (isnull()):
o For each cell in the DataFrame, check if the value is missing (NaN or None).
o Return a DataFrame of the same shape with boolean values (True for missing
values and False for non-missing values).
7. Fill Missing Data with Statistical Values (fillna() with mean, median, etc.):
o Compute the mean or median of the column.
o Replace missing values in the column with the computed mean or median.
o Return a new DataFrame with imputed values.
Ex No: 29
Date: STORE SALES PREDICTION USING MACHINE LEARNING
ALGORITHM
Aim:
To write a python code to apply machine learning model (Linear regression) to
predict the sales of a store.
Algorithm:
Step 1: Import Required Libraries
Fit the training data into the Simple Linear Regression Model.
Extract the slope (m) and intercept (b) of the regression line.
Aim:
To write a python code to perform credit card predictions using decision tree.
Algorithm:
The dataset includes financial details like income, credit score, debt, and approval
status.