0% found this document useful (0 votes)
21 views15 pages

Artificial Intelligence

Uploaded by

dakshahuja1425
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)
21 views15 pages

Artificial Intelligence

Uploaded by

dakshahuja1425
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
You are on page 1/ 15

Artificial Intelligence

Practical File
Session: 2024-25

Name: Daksh Ahuja


Class: 10th-C
Roll: 9
Submitted To:
Ms.Muskan
1. Write a program to accept two integers and print their sum.

Code:
num1 = int(input("Enter the first
integer: ")) num2 = int(input("Enter the
second integer: ")) print("The sum is:",
num1 + num2)

2. Write a program to accept two integers and print their subtraction.

Code:
num1 = int(input("Enter the first
integer: ")) num2 = int(input("Enter the
second integer: "))
print("The result of subtraction is:", num1 - num2)

3. Write a program to accepts two integers and print

their product Code:


num1 = int(input("Enter the first
integer: ")) num2 = int(input("Enter the
second integer: ")) print("The product
is:", num1 * num2)
4. Write a program to read two numbers and print the quotient/division.

Code:
num1 = float(input("Enter the dividend:
")) num2 = float(input("Enter the
divisor: ")) print("The quotient is:",
num1 / num2)

5. Write a program that accepts radius of a circle and prints its area.

Code:
radius = float(input("Enter the radius of the
circle: ")) area = 3.14 * radius ** 2
print("The area of the circle is:", area)

6. Write a program that accepts base and height and calculate the area of the triangle.

Code:
base = float(input("Enter the base of the
triangle: ")) height = float(input("Enter the
height of the triangle: ")) area = 0.5 * base *
height
print("The area of the triangle is:", area)
7. Write a program that inputs a student’s marks in three subjects (out of 100) and prints the
percentage marks.

Code:
marks1 = float(input("Enter marks for the first subject (out of
100): ")) marks2 = float(input("Enter marks for the second subject
(out of 100): ")) marks3 = float(input("Enter marks for the third
subject (out of 100): "))

total_marks = marks1 + marks2 +


marks3 percentage = (total_marks /
300) * 100

print("The percentage marks are:", percentage)

8. Write a program to input side of a square and compute area of square.

Code:
side = float(input("Enter the side length of the
square: ")) area = side ** 2
print("The area of the square is:", area)
9. Write a program to input length and breadth and display perimeter of rectangle.

Code:
length = float(input("Enter the length of the
rectangle: ")) breadth = float(input("Enter the
breadth of the rectangle: ")) perimeter = 2 * (length
+ breadth)
print("The perimeter of the rectangle is:", perimeter)

10.Write a program to accept principal, rate and time and calculate simple interest.

Code:
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the rate of interest (as a
percentage): ")) time = float(input("Enter the time period
(in years): ")) simple_interest = (principal * rate * time) /
100
print("The simple interest is:", simple_interest)
11.Write a program to accept a number and check whether it is even no or odd no.

Code:
number = int(input("Enter a
number: ")) if number % 2 == 0:
print("The number is even.")
else:
print("The number is odd.")

12.Write a program to accept a number and check whether number is positive or negative.

Code:
number = float(input("Enter a
number: ")) if number > 0:
print("The number is
positive.") elif number < 0:
print("The number is negative.")
else:
print("The number is zero.")

13.Write a program to accept two numbers and find out greatest out of two numbers.

Code:
num1 = float(input("Enter the first
number: ")) num2 = float(input("Enter the
second number: ")) if num1 > num2:
print("The greatest number is:", num1)
else:
print("The greatest number is:", num2)
14.Write a program to accept two numbers and find out smallest out of two numbers

Code:
num1 = float(input("Enter the first
number: ")) num2 = float(input("Enter the
second number: ")) if num1 < num2:
print("The smallest number is:", num1)
else:
print("The smallest number is:", num2)

15.Write a program to accept three numbers and find out greatest out of two numbers.

Code:
num1 = float(input("Enter the first
number: ")) num2 = float(input("Enter the
second number: ")) num3 =
float(input("Enter the third number: "))
greatest = num1
if num2 > greatest:
greatest =
num2 if num3 >
greatest:
greatest = num3
print("The greatest number is:", greatest)
16.Write a program to accept three numbers and find out smallest out of two numbers.

Code:
num1 = float(input("Enter the first
number: ")) num2 = float(input("Enter the
second number: ")) num3 =
float(input("Enter the third number: "))
smallest = num1
if num2 < smallest:
smallest =
num2 if num3 <
smallest:
smallest = num3
print("The smallest number is:", smallest)

17.Write a program to accept a number and display its table.

Code:
number = int(input("Enter a
number: ")) for i in range(1, 11):
print(f"{number} x {i} = {number * i}")
18.Write a program to accept a number and calculate its factorial.

Code:
number = int(input("Enter a number: "))
factorial = 1
for i in range(1, number + 1):
factorial *= i
print("The factorial of", number, "is:", factorial)

19.Write a program to display the following structure:


*
**
***
****

Code:
for i in range(1,
5): for j in
range(i):
print('*',
end='') print()

20.Write a program to print first 20 numbers of Fibonacci series.

Code:
a, b = 0, 1
for _ in range(20):
print(a,
end=' ') a, b
= b, a + b
21.Write a program to display the concept of Series using Pandas.

Code:
import pandas as pd

data = [10, 20, 30, 40, 50]


series = pd.Series(data)
print(series)

22.Write a program to display Month name and number of days in that month using Pandas series.

Code:
import pandas as
pd data = {
'January': 31, 'February': 28, 'March': 31, 'April': 30, 'May': 31, 'June': 30, 'July': 31, 'August': 31,
'September':
30, 'October': 31, 'November': 30, 'December': 31
}
series = pd.Series(data)
print(series)
23.Write a program to display Name and Marks of your 5 friends using Dataframe.

Code:
import pandas as pd

data = {
'Name': ['Alice', 'Bob', 'Charlie', 'David',
'Eve'], 'Marks': [85, 90, 78, 92, 88]
}

df =
pd.DataFrame(data)
print(df)

24.Write a program to display your different subject marks using Dataframe.

Code:
import pandas as pd

data = {
'Subject': ['Math', 'Science', 'English', 'History',
'Art'], 'Marks': [95, 88, 76, 85, 90]
}

df =
pd.DataFrame(data)
print(df)
25.Write a program to calculate the statistical values- Mean, Median and Mode using Numpy.

Code:
import numpy as np

data = [10, 20, 20, 30, 40, 50, 60, 70, 80, 90]

mean =
np.mean(data) median
= np.median(data)
mode = np.argmax(np.bincount(data))

print("Mean:", mean)
print("Median:",
median)
print("Mode:", mode)

26.Write a program to analyze sales data using Numpy Arrays.

Code:
import numpy as np

sales = np.array([150, 200, 250, 300, 180, 220, 270])


total_sales = np.sum(sales)
average_sales =
np.mean(sales) max_sales =
np.max(sales) min_sales =
np.min(sales) median_sales =
np.median(sales)
std_dev_sales = np.std(sales)

print("Total Sales:", total_sales)


print("Average Sales:",
average_sales) print("Maximum
Sales:", max_sales)
print("Minimum Sales:",
min_sales) print("Median Sales:",
median_sales)
print("Standard Deviation of Sales:", std_dev_sales)
27.Write a program to print the string in reverse order.

Code:
string = input("Enter a
string: ") print(string[::-1])

28.Write a program to display Salaries and work experience using line chart.

Code:
import matplotlib.pyplot as plt

experience = [1, 2, 3, 4, 5]
salaries = [30000, 35000, 40000, 45000, 50000]

plt.plot(experience, salaries, marker='o')

plt.title('Salaries vs. Work Experience')


plt.xlabel('Years of Experience')
plt.ylabel('Salary')

plt.grid(Tru
e)
plt.show()
29.Write a program to display book title and sales using bar chart.

import matplotlib.pyplot as plt


titles = ['Book A', 'Book B', 'Book C',
'Book D'] sales = [500, 300, 450, 600]
plt.bar(titles,
sales)
plt.title('Book
Sales')
plt.xlabel('Book
Title')
plt.ylabel('Sales')
plt.show()

30.Write a program to display distribution of Students percentage using

Histogram. import matplotlib.pyplot as plt


percentages = [55, 60, 65, 70, 75, 80, 85, 90, 95, 100]
plt.hist(percentages, bins=5, edgecolor='black')
plt.title('Distribution of Students Percentage')
plt.xlabel('Percentage')
plt.ylabel('Number of Students')
plt.show()

You might also like