0% found this document useful (0 votes)
9 views29 pages

A.I Practical 9th PDF

Uploaded by

naitikking01
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)
9 views29 pages

A.I Practical 9th PDF

Uploaded by

naitikking01
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/ 29

CENTRAL BOARD OF SECONDARY EDUCATION

SANT CHAVARA NATIONAL ACADEMY

CHANDAMETA

A PRACTICAL RECORD FILE IS SUBMITTED FOR THE


ARTIFICIAL INTELLIGENCE CLASS 9th
SESSION: 2024-25

SUBMITTED BY:

NAME OF STUDENT: MOHD AZMAL

SUBJECT TEACHER(AI):VISHAL CHOURASIA

CLASS: 9th B

ROLL NO: 29
ACKNOWLEDGEMENT
I wish to express my deep sense of gratitude and indebtedness to
our learned teacher VISHAL CHOURASIA
, TGT COMPUTER, SANT CHAVAR NATIONAL ACADEMY
for his invaluable help, advice and guidance in the preparation of
this project.

I am also greatly indebted to our principal FR.FRANCIS and school


authorities for providing me with the facilities and requisite
laboratory conditions for making this practical file.

I also extend my thanks to a number of teachers, my classmates


and friends who helped me to complete this practical file
successfully.

MOHD AZMAL
CERTIFICATE

This is to certify that M O H D A Z M A L , student of class IX”B”


SANT CHAVARA NATIONAL ACADEMY has completed the PRACTICAL

FILE during the academic year 2024-25 towards partial fulfillment of


credit for the ARTIFICIAL INTELLIGENCE practical evaluation of
2024-25 and submitted satisfactory report, as compiled in the
following pages, under my supervision.

Total number of practical certified are : 15.

Internal Examiner Principal

SignatureSignature

Date:
No Practical Date Signature

What is python? Write some important features


1 25/01/2025
of Python.

Define variables and data types in Python. How

2 do you assing a variables?


25/01/2025

Write a program to input two numbers and


25/01/2025
3 display their sum.

Write a program to interchange the value of two


4 variables. 25/01/2025

Write a program to calculate the volume of a


5 cylinder. 25/01/2025

Write a program to calculate the simple interest.


6 25/01/2025

Find the area of a rectangle whose length and


7 breadth are 25cm and 20 cm respectively. 25/012025

Write a program to find the area of circle.(Take


8 radius as user input). 25/01/2025

Write a program to compare two numbers and

i h bi
print the bigger one. 25/01/2025
9
Write a program to display one of the alternate
10 message. 25/01/2025

Write a program to find given number is even or


11 odd. 25/01/2025

Write a program to find given number is positive


12 or negative. 25/01/2025

Write a program to compare three numbers and


13 print the largest of them. 25/01/2025

Accept the value from user and calculate the


14 area and printer of rectangle. 25/01/2025

Write a program to check given number is


positive, zero or negative prepare all program
15 with their output. 25/01/2025

Q1. What is python? Write some important features of Python.

ANSWER: Python is a high-level, interpreted programming language known for its


simplicity and readability. Created by Guido van Rossum in 1991, it is widely used for various
purposes, including web development, data analysis, artificial intelligence, machine learning,
automation, and more.

Important Features of Python


1. Easy to Learn and Use: Python has a simple and easy-to-read syntax, making it beginner-
friendly.

2. Interpreted Language: Python code is executed line by line, making debugging easier.

3. Dynamically Typed: Variable types are determined at runtime, so there is no need to


declare them explicitly.

4. Object-Oriented: Python supports object-oriented programming concepts like classes and


objects, enabling reusable code.

5. Extensive Libraries: Python comes with a vast collection of standard libraries, such as
NumPy, pandas, and matplotlib, which make it powerful for various applications.

6. Platform-Independent: Python code can run on different platforms (Windows, macOS,


Linux) without requiring modifications.

7. High-Level Language: Python allows you to focus on problem-solving rather than low-level
system details.

8. Supports Multiple Paradigms: It supports multiple programming paradigms, including


procedural, object-oriented, and functional programming.
9. Large Community: Python has a vast community of developers, which ensures continuous
updates, tutorials, and libraries.

10. Automation-Friendly: It is widely used for scripting and automating repetitive tasks.

Q2. Define variables and data types in Python. How do you assing a
variables?

ANSWER: Variables in Python:

A variable is a named location in memory used to store data that can be modified during
program execution. Variables are like containers that hold information.

Data Types in Python:

Data types define the kind of value a variable holds. Python is dynamically typed, meaning
you don’t need to specify the type of variable when declaring it; Python infers the type based
on the value assigned. Common data types in Python include:

1. Numeric Types:

int: Integer numbers (e.g., 5, -10).

float: Floating-point numbers (e.g., 3.14, -2.71).

complex: Complex numbers (e.g., 3+4j).

2. Sequence Types:
str: Strings (e.g., "hello").

list: Ordered and mutable collection (e.g., [1, 2, 3]).

tuple: Ordered and immutable collection (e.g., (1, 2, 3)).

3. Mapping Type:

dict: Collection of key-value pairs (e.g., {"name": "John", "age": 25}).

4. Set Types:

set: Unordered and mutable collection of unique items (e.g., {1, 2, 3}).

frozenset: Immutable version of a set.

5. Boolean Type:

bool: Logical values (True or False).

6. None Type:
NoneType: Represents a null value (None).

Assigning a Value to a Variable:

In Python, you can assign a value to a variable using the assignment operator (=). The syntax
is:

variable_name = value

Example:

# Assigning values to variables


x = 10 # x is an integer

y = 3.14 # y is a float
name = "Jatin" # name is a string

is_active = True # is_active is a boolean


fruits = ["apple", "banana", "cherry"] # fruits is a list

Rules for Naming Variables:

1. Must begin with a letter (a-z, A-Z) or an underscore _.

2. Can contain letters, numbers (0-9), and underscores.


3. Cannot use reserved keywords (e.g., if, else, class).

4. Variables are case-sensitive (Name and name are different).

Q3. Write a program to input two numbers and display their sum.

ANSWER: # Define the two numbers

num1 = 1
num2 = 2

# Calculate the sum


sum = num1 + num2

# Display the result

print("The sum of", num1, "and", num2, "is:", sum)

Output:

The sum of 1 and 2 is: 3.


Q4. Write a program to interchange the value of two variables.
ANSWER: Here’s the Python program with the values of a = 5 and b = 10:

# Initializing values
a=5

b = 10

# Display original values


print("Before swapping:")

print(f"a = {a}")
print(f"b = {b}")

# Swapping the values


temp = a

a=b
b = temp

# Display swapped values

print("\nAfter swapping:")
print(f"a = {a}")

print(f"b = {b}")

Output:

Before swapping:

a=5
b = 10

After swapping:
a = 10
b=5

Q5. Write a program to calculate the volume of a cylinder.

ANSWER: int(input(“enter the radius of the cylinder (in cm) - ”))

h= int(input(“enter the height of the cylinder (in cm)- ”))


pi=3.15

volume=3.15*r*r*h
print(“volume of the cylinder is -”,volume,)

OUTPUT:
enter the radius of the cylinder – 7
enter the height of the cylinder – 11

volume of the cylinder is – 1698.85 cubic units


Q6. Write a program to calculate the simple interest.

ANSWER: Here’s a Python program to calculate Simple Interest:

# Taking input from the user


principal = float(input("Enter the principal amount: "))

rate = float(input("Enter the rate of interest (in %): "))


time = float(input("Enter the time (in years): "))

# Calculating simple interest

simple_interest = (principal * rate * time) / 100

# Displaying the result

print(f"The Simple Interest is: {simple_interest}")

Example Output 1:

Enter the principal amount: 1000


Enter the rate of interest (in %): 5

Enter the time (in years): 2


The Simple Interest is: 100.0

Example Output 2:

Enter the principal amount: 5000


Enter the rate of interest (in %): 7

Enter the time (in years): 3


The Simple Interest is: 1050.0
This program takes the principal amount, interest rate, and time as input and calculates the
simple interest using the formula:
Simple Interest = (Principal × Rate × Time) / 100.

Q7. Find the area of a rectangle whose length and breadth are 25cm and
20 cm respectively.

ANSWER: # Define length and breadth

length = 25 # in cm
breadth = 20 # in cm

# Calculate the area

area = length * breadth


# Display the area
print(f"The area of the rectangle is {area} square cm.")

If you run this, it will output:

The area of the rectangle is 500 square cm.


Q8. Write a program to find the area of circle.(Take radius as user
input).

ANSWER: Here’s a Python program to calculate the area of a circle by taking the radius as
input:

# Taking the radius as input from the user


radius = float(input("Enter the radius of the circle: "))

# Calculating the area of the circle

area = pi * radius * radius

# Displaying the result


print(f"The area of the circle with radius {radius} is: {area:.2f}")

Example Output 1:

Enter the radius of the circle: 5


The area of the circle with radius 5.0 is: 78.54

Example Output 2:

Enter the radius of the circle: 10


The area of the circle with radius 10.0 is: 314.16
Q9. Write a program to compare two numbers and print the bigger one.

ANSWER: Here's a Python program to compare two numbers and print the bigger one:

# Take two numbers as input from the user

num1 = float(input("Enter the first number: "))


num2 = float(input("Enter the second number: "))
# Compare the numbers and find the bigger one

if num1 > num2:


print(f"The bigger number is {num1}.")

elif num2 > num1:


print(f"The bigger number is {num2}.")

else:
print("Both numbers are equal.")

How it works:

1. The program takes two numbers as input from the user.

2. It compares the two numbers using if, elif, and else conditions.

3. It prints which number is bigger or whether they are equal.

Example Output:

Case 1:

Enter the first number: 12


Enter the second number: 15

The bigger number is 15.


Case 2:

Enter the first number: 20


Enter the second number: 20

Both numbers are equal.

Q10. Write a program to display one of the alternate message.

ANSWER: Here is a simple Python program that displays one of two alternative messages
based on a condition:

# Take user input to choose an option


choice = input("Enter '1' or '2' to display a message: ")

# Display one of the two messages based on the input

if choice == '1':
print("You selected the first option: Have a great day!")
elif choice == '2':

print("You selected the second option: Keep up the good work!")


else:

print("Invalid choice. Please enter '1' or '2'.")

How it works:

1. The program asks the user to input either 1 or 2.


2. Based on the input, it displays one of the two predefined messages.

3. If the input is invalid, an error message is displayed.

Example Outputs:

Case 1:

Enter '1' or '2' to display a message: 1


You selected the first option: Have a great day!

Case 2:

Enter '1' or '2' to display a message: 2


You selected the second option: Keep up the good work!

Case 3:

Enter '1' or '2' to display a message: 3


Invalid choice. Please enter '1' or '2'.

Q11. Write a program to find given number is even or odd.


ANSWER: Here is a Python program to check whether a given number is even or odd:

# Take input from the user

number = int(input("Enter a positive number: "))

# Check if the number is even or odd

if (number % 2 == 0) :

print(“The number ", number, "is EVEN”)

else:
print(“The number", number, "is ODD”)

Example Outputs:

Case 1:

Enter a number: 8

8 is an even number.

Case 2:

Enter a number: 15

15 is an odd number.
Q12. Write a program to find given number is positive or negative.
ANSWER: Here's a Python program that checks whether a given number is positive or
negative:

# Take input from the user


number = int(input("Enter a non zero number: "))

# Check if the number is positive, negative, or zero


if number > 0:

print(“the number ", n, "is a positive number. ”)


elif number < 0:

print(“The number ", n, "is a negative number”)


else:

print(“The number", n,"is zero”)

Example Outputs:
Case 1:

Enter a number: 12
12.0 is a positive number.

Case 2:
Enter a number: -5
-5.0 is a negative number.
Case 3:

Enter a number: 0
The number is zero.

Q13.Write a program to compare three numbers and print the largest of


them.
ANSWER: Here’s a Python program to compare three numbers and print the largest one:
a = int(input(“enter the first number : ”))

b = int(input(“enter the second number : ”))


c = int(input(“enter the third number : ”))

if a>b & a>c :

print (“The biggest number is : ” , a)

elif b>a & b>c :


print(“The biggest number is : ”, b)

else :
print(“The biggest number is : ” , c)

OUTPUT :
Enter the first number : 34
Enter the second number : 54

Enter the third number : 22


The biggest number is : 54
Q14. Accept the value from user and calculate the area and perimeter of
rectangle.
ANSWER: Here's a simple Python program that takes the length and width of a rectangle
from the user and calculates both its area and perimeter:

# Taking input from the user

length = float(input("Enter the length of the rectangle: "))


width = float(input("Enter the width of the rectangle: "))

# Calculating the area of the rectangle

area = length * width

# Calculating the perimeter of the rectangle

perimeter = 2 * (length + width)

# Displaying the results


print(f"The area of the rectangle is: {area}")

print(f"The perimeter of the rectangle is: {perimeter}")

Example Output 1:

Enter the length of the rectangle: 5

Enter the width of the rectangle: 3


The area of the rectangle is: 15.0

The perimeter of the rectangle is: 16.0


Example Output 2:

Enter the length of the rectangle: 7.5


Enter the width of the rectangle: 4.2

The area of the rectangle is: 31.5


The perimeter of the rectangle is: 23.4

Q15. Write a program to check given number is positive, zero or negative


prepare all program with their output.
ANSWER: Here’s a Python program to check if a given number is positive, zero, or negative:
# Taking input from the user

number = float(input("Enter a number: "))

# Checking if the number is positive, zero, or negative


if number > 0:

print("The number is positive.")


elif number == 0:

print("The number is zero.")


else:

print("The number is negative.")

Example Output 1 (Positive Number):

Enter a number: 5
The number is positive.

Example Output 2 (Zero):

Enter a number: 0
The number is zero.

Example Output 3 (Negative Number):

Enter a number: -3
The number is negative.

You might also like