0% found this document useful (0 votes)
8 views32 pages

Class 10 AI Practical Assignments

This document is a practical file for Class 10 Artificial Intelligence for the session 2025-2026, submitted by Yashasvi Narwal. It includes a list of practical assignments with corresponding program codes for various tasks such as finding sums, checking even/odd numbers, converting units, and creating patterns. Each program is detailed with code snippets and explanations for educational purposes.

Uploaded by

niphix16
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)
8 views32 pages

Class 10 AI Practical Assignments

This document is a practical file for Class 10 Artificial Intelligence for the session 2025-2026, submitted by Yashasvi Narwal. It includes a list of practical assignments with corresponding program codes for various tasks such as finding sums, checking even/odd numbers, converting units, and creating patterns. Each program is detailed with code snippets and explanations for educational purposes.

Uploaded by

niphix16
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

SWARNPRASTHA PUBLIC SCHOOL

SESSION: 2025-2026
Class 10 Prac cal File (2025-26)
ARTIFICIAL INTELLIGENCE
Subject Code: 417
Submi ed by: Yashasvi Narwal
Submi ed to: Mr. Arjun Dhama
Submission Date:
[Link] PRACTICAL ASSIGNMENT [Link] SIG.

1. Find the sum of natural numbers. 1

2. Program to find even or odd numbers . 2

3. Program to check whether the given letter is a vowel or a 4


consonant.

4. Convert meter into centimetre… 5

5. Write a program to calculate the series. 9

6. Write a program to 10
(a) ask the user to enter the marks of the student
(b) find the total and aggregate % of the student….
7. Write a program to obtain temperature in Celsius and 12
convert it into Fahrenheit using formula °C * 9/5+35=°F.

8. Write a program to print the table of any number entered 13


by user.

9. Write a program to print pattern 14

10. Write a program to print pattern 15

11. write a program to reverse any number using while loop 16


.
12. Program to input the marks from users and print the 17
grades accordingly.

13. Create a simple calculator using if-elif-else statement. 19

14. Program to print the greatest number among the three 21


numbers.

15 Perform the following operations on the list 22


created above in a sequence. (a) Print the whole list
(b) Delete the name “Vikram” from the list
(c) add the name “Jai” at the end
(d) Remove the item which is at second position
16 Create a list num= [23,12,5,9,65,44] 23
(a) print the length of the list
(b) print the elements from second to fourth position
using positive indexing.
(c) print the elements from position third to fifth
using negative indexing.
17 Write a program that reads a line and prints its statistics 24
like: (a) Number of uppercase letters:
(b) Number of lowercase letters:
(c) Number of alphabets:
(d) Number of digits:
18 Write a program to convert the string in Upper case if it 26
in Lower case and vice versa.

19 Write a program to create a list [‘e’,’i’,’q’,’a’,’p’] and 27


the list in sorted form.
20 Write a program to concatenate two strings. 28
Str1=” Artificial”
Str2=” Intelligence”
PROGRAM -1 pg.1

Find the sum of natural numbers.

Code-

def sum_using_loop(n):
total = 0
for i in range(1, n + 1):
total += i
return total
num = 10
print(f"The sum of the first {num} numbers is: {sum_using_loop(num)}")
PROGRAM-02 (A part) pg.2

Program to find first 10 even numbers .


Code-
for i in range(1, 11):
print(i * 2)
PROGRAM-2 ( B Part ) pg.3
Program to find first 10 odd numbers .
Code-
print("The first ten odd numbers are:")
for i in range(1, 11):
odd_number = 2 * i - 1
print(odd_number)
PROGRAM-03 pg.4
Program to check whether the given letter is a vowel or a consonant.
Code-
char = input("Enter a letter: ").lower()
if len(char) == 1 and [Link]():
if char in 'aeiou':
print(f"{char} is a vowel.")
else:
print(f"{char} is a consonant.")
else:
print("Please enter a single valid letter.")
PROGRAM-04 pg.5
- Convert meter into centimeter
Code-
meters = float(input("Enter length in meters: "))
centimeters = meters * 100
print(f"{meters} m is equal to {centimeters} cm")
pg.6
Convert centimeter into meter

Code-
cm = float(input("Enter length in centimeters: "))
meters = cm / 100
print(f"{cm} cm is equal to {meters} m")
cm = float(input("Enter length in centimeters: "))
meters = cm / 100
print(f"{cm} cm is equal to {meters} m")
pg.7
- Convert kilometer into meter
Code-
km = float(input("Enter length in kilometers: "))
meters = km * 1000
print(f"{km} km is equal to {meters} m")
pg.8
Convert meter to kilometer
Code-
meters = float(input("Enter length in meters: "))
km = meters / 1000
print(f"{meters} m is equal to {km} km")
PROGRAM – 05 pg.9

Write a program to calculate the series


1+n2+n3+n4 (n is any number entered by user)

Code-
n = float(input("Enter the value of n: "))
result = 1 + n**2 + n**3 + n**4
print("The result of the series is: ", result)
PROGRAM – 06 pg.10

(a) ask the user to enter the marks of the student


(b) find the total and aggregate % of the student.
(c) display the grade of the students as per the following criteria.

Code-
marks = []
for i in range(1, 4):
m = float(input("Enter marks for subject " + str(i) + ": "))
[Link](m)

total = sum(marks)
perc = (total / 300) * 100

if perc >= 80:


grade = "A"
elif perc >= 60:
grade = "B"
elif perc >= 40:
grade = "C"
else:
grade = "Fail"

print("Total:", total)
print("Percentage:", perc, "%")
print("Grade:", grade)
pg.11
PROGRAM – 07 pg.12

Write a program to obtain temperature in Celsius and convert it


[Link] using formula °C * 9/5+35=°F.

Code-
celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = celsius * 9 / 5 + 35
print("Temperature in Fahrenheit:", fahrenheit)
PROGRAM – 08 pg.13

Write a program to print the table of any number entered by user.


Code-

num = int(input("Enter the number for the table: "))


for i in range(1, 11):
print(num, "x", i, "=", num * i)
PROGRAM-09 pg.14
Write a program to print
*
**
***
****
*****

Code-
for i in range(1, 6):
print("* " * i)
PROGRAM-10 pg.15
Write a program to print
*****
****
***
**
*
Code-

for i in range(5, 0, -1):


print("* " * i)
PROGRAM-11 pg.16
Write a program to reverse any number using while loop.

Code-
num = int(input("Enter a number: "))
reverse = 0
while num > 0:
remainder = num % 10
reverse = (reverse * 10) + remainder
num = num // 10
print("Reversed Number:", reverse)
PROGRAM-12 pg.17
Program to input the marks from users and print the grades accordingly.

Code-
marks = float(input("Enter the marks obtained: "))
if marks >= 90:
grade = "A+"
elif marks >= 80:
grade = "A"
elif marks >= 70:
grade = "B"
elif marks >= 60:
grade = "C"
elif marks >= 50:
grade = "D"
elif marks >= 33:
grade = "E"
else:
grade = "F (Fail)"
print("The Grade is:", grade)
Pg. 18
PROGRAM-13 pg.19
Create a simple calculator using if-elif-else statement.

Code-
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
print("Choose operation: + , - , * , /")
op = input("Enter operator: ")

if op == "+":
result = num1 + num2
print("Result:", result)
elif op == "-":
result = num1 - num2
print("Result:", result)
elif op == "*":
result = num1 * num2
print("Result:", result)
elif op == "/":
if num2 != 0:
result = num1 / num2
print("Result:", result)
else:
print("Error! Division by zero is not allowed.")
else:
print("Invalid operator!")
pg.20
PROGRAM-14 pg.21
Program to print the greatest number among the three numbers.
Code-
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
c = float(input("Enter third number: "))
if a >= b and a >= c:
greatest = a
elif b >= a and b >= c:
greatest = b
else:
greatest = c
print("The greatest number is:", greatest)
PROGRAM-15 pg.22
Perform the following operations on the list created above in a sequence.
(a) Print the whole list
(b) Delete the name “Vikram” from the list
(c) add the name “Jai” at the end
(d) Remove the item which is at second position

Code-

names = ["Amit", "Vikram", "Sonia", "Rahul"]

print("Original list:", names)

[Link]("Vikram")

print("After deleting Vikram:", names)

[Link]("Jai")

print("After adding Jai at the end:", names)

[Link](1)

print("After removing item at second position:", names)


PROGRAM-16 pg.23
Create a list num= [23,12,5,9,65,44]
(a) print the length of the list
(b) print the elements from second to fourth position using positive
indexing.
(c) print the elements from position third to fifth using negative indexing.

Code-
num = [23, 12, 5, 9, 65, 44]
print("Length of the list:", len(num))
print("Elements from 2nd to 4th (Positive):", num[1:4])
print("Elements from 3rd to 5th (Negative):", num[-4:-1])
PROGRAM-17 pg.24
Write a program that reads a line and prints its statistics like:
(a) Number of uppercase letters:
(b) Number of lowercase letters:
(c) Number of alphabets:
(d) Number of digits:

Code-
line = input("Enter a line of text: ")
upper_count = 0
lower_count = 0
alpha_count = 0
digit_count = 0
for char in line:
if [Link]():
upper_count += 1
if [Link]():
lower_count += 1
if [Link]():
alpha_count += 1
if [Link]():
digit_count += 1
print("Number of uppercase letters:", upper_count)
print("Number of lowercase letters:", lower_count)
print("Number of alphabets:", alpha_count)
print("Number of digits:", digit_count)
pg.25
PROGRAM-18 pg.26
Write a program to convert the string in Upper case if it in Lower case and
vice versa.
Code-
text = input("Enter a string: ")
swapped_text = ""
for char in text:
if [Link]():
swapped_text += [Link]()
elif [Link]():
swapped_text += [Link]()
else:
swapped_text += char
print("Converted string:", swapped_text)
PROGRAM-19 pg.27
Write a program to create a list [‘e’,’i’,’q’,’a’,’p’] and the list in sorted
form.

Code-
chars = ['e', 'i', 'q', 'a', 'p']
print("Original list:", chars)
[Link]()
print("Sorted list:", chars)
PROGRAM-20 pg.28
Write a program to concatenate two strings.
Str1=” Artificial”
Str2=” Intelligence”

Code-
Str1 = "Artificial"
Str2 = "Intelligence"
result = Str1 + " " + Str2
print("Combined String:", result)

You might also like