0% found this document useful (0 votes)
207 views11 pages

Class X - AI (417) Practical File 2024-25

The document is a practical file for Class X AI, submitted by Sreedev Subhash Kartha, containing various programming exercises related to data science using Python, NumPy, and Pandas. It includes eight programs with source code and outputs demonstrating tasks such as converting lists to NumPy arrays, concatenating lists, creating matrices, appending values to lists, and creating dataframes. Each program is accompanied by a description, source code, and the expected output.

Uploaded by

subhashsreedev8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
207 views11 pages

Class X - AI (417) Practical File 2024-25

The document is a practical file for Class X AI, submitted by Sreedev Subhash Kartha, containing various programming exercises related to data science using Python, NumPy, and Pandas. It includes eight programs with source code and outputs demonstrating tasks such as converting lists to NumPy arrays, concatenating lists, creating matrices, appending values to lists, and creating dataframes. Each program is accompanied by a description, source code, and the expected output.

Uploaded by

subhashsreedev8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Class X – AI (417)

Practical File 2024-25

Submitted by : Sreedev Subhash Kartha

Class & Section : X-R

ID number : 22000

Teacher Name : SANGEETHA SARAVANAN

Teacher Sign : __________________


1

INDEX

PART - B

DATA SCIENCE (LIST, Numpy & Pandas)

No. Title Date Signature

1 Write a program to convert a


python list to a NumPy array

2 Write a program to concatenate the


elements of the two lists.

3 Write a program to develop a matrix


of 3×3 with values from 30 to 39.

4 WAP to append a value to an


existing list

5 Create a 2 dimensional array with 3


rows and 4 columns(using ones in
integer data type)

6 Get all elements the fourth element


from the following array. arr=[‘den’,
‘pen’, ‘hen’, ‘ren’, ‘lem’, ‘men’]

7 Get first, third and fourth elements


and add them from the following
array. arr=[34,56,76,89,70,67]

8 Create a dataframe with the given


data
2

Program-1:

Write a program to convert a python list to a NumPy array

Source-Code:
import numpy as np

python_list = [1, 2, 3, 4, 5]

numpy_array = np.array(python_list)

print("Python List:", python_list)

print("NumPy Array:", numpy_array)

Output:
Python List: [1, 2, 3, 4, 5]

NumPy Array: [1 2 3 4 5]
3

Program-2:

Write a program to concatenate the elements of the two lists.

Source-Code:
list1 = [1, 2, 3]

list2 = [4, 5, 6]

concatenated_list = list1 + list2

print("List 1:", list1) print("List 2:", list2) print("Concatenated List:",


concatenated_list)

Output:

List 1: [1, 2, 3]

List 2: [4, 5, 6]

Concatenated List: [1, 2, 3, 4, 5, 6]


4

Program-3

Write a program to develop a matrix of 3×3 with values from 30 to 39.

Source-Code:
import numpy as np

matrix = np.arange(30, 39+1).reshape(3, 3)

print("3x3 Matrix:")

print(matrix)

Output:

3x3 Matrix: [[30 31 32] [33 34 35] [36 37 38]]


5

Program-4:

Write a program to append a value to an existing list

Source Code:
my_list = [1, 2, 3, 4, 5]

value_to_append = 6

my_list.append(value_to_append)

print("Updated List:", my_list)

Output:
Updated List: [1, 2, 3, 4, 5, 6]
6

Program-5:

Create a 2-dimensional array with 3 rows and 4 columns (using


ones in integer data type)

Source-Code:
import numpy as np

array = np.ones((3, 4), dtype=int)

print("2D Array with 3 rows and 4 columns filled with ones:") print(array)

Output
2D Array with 3 rows and 4 columns filled with ones:

[[1 1 1 1] [1 1 1 1] [1 1 1 1]]
7

Program-6:
Get all elements the fourth element from the following array. arr=[‘den’,
‘pen’, ‘hen’, ‘ren’, ‘lem’, ‘men’]

Source-Code:

arr = ['den', 'pen', 'hen', 'ren', 'lem', 'men']

fourth_element = arr[3]

print("The fourth element is:", fourth_element)

Output

The fourth element is: ren


8

Program-7:

Get first, third and fourth elements and add them from the
following array. arr = [34,56,76,89,70,67]

Source-Code:

arr = [34, 56, 76, 89, 70, 67]

first_element = arr[0]

third_element = arr[2]

fourth_element = arr[3]

sum_of_elements = first_element + third_element + fourth_element

print("The sum of the first, third, and fourth elements is:",


sum_of_elements)

Output

The sum of the first, third, and fourth elements is: 199
9

Program-8:

Create a dataframe with the given data

Source Code:

import pandas as pd

data = { "Name": ["Sanjeev", "Keshav", "Rahul"], "Age": [37, 42, 38], "Designation":
["Manager", "Clerk", "Accountant"] }

df = pd.DataFrame(data)

print(df)

Output:
Name Age Designation
0 Sanjeev 37 Manager
1 Keshav 42 Clerk
2 Rahul 38 Accountant
10

You might also like