0% found this document useful (0 votes)
2 views5 pages

Class 10 AI Practical File Basic Program Recap

This document is a practical file for an Artificial Intelligence course at Delhi Public School-Bopal, Ahmedabad, for the session 2026-2027. It includes instructions for writing programs in Python covering various topics such as conditional statements, loops, and string manipulation, along with specific programming tasks. Each task requires the student to write the question, code, and output, with examples provided for each programming question.

Uploaded by

stavyasoni916
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)
2 views5 pages

Class 10 AI Practical File Basic Program Recap

This document is a practical file for an Artificial Intelligence course at Delhi Public School-Bopal, Ahmedabad, for the session 2026-2027. It includes instructions for writing programs in Python covering various topics such as conditional statements, loops, and string manipulation, along with specific programming tasks. Each task requires the student to write the question, code, and output, with examples provided for each programming question.

Uploaded by

stavyasoni916
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

DELHI PUBLIC SCHOOL-BOPAL, AHMEDABAD

Subject: ARTIFICIAL INTELLIGENCE Session: 2026-2027


Practical File-1 Unit 2: Advanced Python-Programs on conditional statements, loops, string, list
---------------------------------------------------------------------------------------------------------------------------------------
Instructions:
1. Write Name, Class & Sec, Admn No & Roll No in the top-right corner of every page.
2. Write all programs on A4 sheets.
3. For each program, include the Question, Code, and the Output (Paste a screenshot of the output
below the code.).
4. Begin each program on a new page.
5. You may use both sides of the paper.

Question 1:
WAP to determine the type of triangle based on the lengths of its three sides. The program should
classify the triangle as one of the following:
Equilateral Triangle: All three sides are equal.
Isosceles Triangle: Any two sides are equal.
Scalene Triangle: All three sides are different.

Code:
a = int(input(“Enter first side: “))
b = int(input(“Enter second side: “))
c = int(input(“Enter third side: “))
if a == b == c:
print(“Equilateral triangle”)
elif a == b or b == c or a == c:
print(“Isosceles triangle”)
else:
print(“Scalene triangle”)

Output:
Paste Screenshot of the output

Question 2:
WAP to create a menu driven program for the following arithmetic operations

Code:
a = float(input(“Enter first number: “))
Page 1 of 5
b = float(input(“Enter second number: “))
print(“Select the appropriate operation: “)
print(“1. Addition”)
print(“2. Subtraction”)
print(“3. Multiplication”)
print(“4. Division”)
choice = int(input(“Enter your choice (1/2/3/4/5): “))
if choice <0 or choice >4:
print(“Invalid choice”)
elif choice == 1:
print(“Result:”, a + b)
elif choice == 2:
print(“Result:”, a – b)
elif choice == 3:
print(“Result:”, a * b)
else:
print(“Result:”, a / b)

Output:
Paste Screenshot of the output

Question 3:
WAP to display the factorial of ‘n’ using for loop.

Code:
n=int(input("Enter a number:-"))
fact=1
for i in range(1,n+1):
fact*=i
print("Factorial of ", n, "is ", fact)

Output:
Paste Screenshot of the output

Question 4:
WAP to reverse a numbers using while loop.

Code:
n=int(input("Enter a number:-"))
n1=n
rev=0
while n1 != 0:
lastdigit=n1%10
rev=rev*10+lastdigit
n1=n1//10
print("Reverse of", n, "is", rev)
Page 2 of 5
Output:
Paste Screenshot of the output

Question 5:
WAP to display first n terms of Fibonacci Series.

Code:
n=int(input("No. of terms:-"))
n1,n2,n3=0,1,0
for i in range(n):
print(n3, end=" ")
n1=n2
n2=n3
n3=n1+n2

Output:
Paste Screenshot of the output

Question 6:
WAP to count vowels & consonants in a string

Code:
s1=input("Enter a string-")
v,c=0,0
for i in s1:
if i in "AEIOUaeiou":
v+=1
elif (i>= "A" and i<= "Z") or (i>= "a" and i<= "z"):
c+=1
print("No. of Vowels=",v)
print("No. of consonants=",c)

Output:
Paste Screenshot of the output

Question 7:
WAP to convert all uppercase to lowercase to uppercase and keep rest of the characters as it is.

Code:
s1=input("Enter a string-")
new= ""
for i in s1:
if i>= "A" and i<= "Z":
new=new+chr(ord(i)+32)
elif i>= "a" and i<= "z":
Page 3 of 5
new=new+chr(ord(i)-32)
else:
new=new+i
print("The original string is", s1)
print("New String is ",new)

Output:
Paste Screenshot of the output

Question 8:
WAP to check whether the given string is a palindrome or not

Code:
s1=input("Enter a string-")
leng=len(s1)-1
for i in s1:
if i!=s1[leng]:
print(s1, "is not a palindrome")
break
leng=leng-1
else:
print(s1, "is a palindrome")

Output:
Paste Screenshot of the output

Question 9:
WAP to get an element from index position

Code:
L1=[16, 21, 45,10,19]
ind=int(input("Index position-"))
print(L1[ind])

Output:
Paste Screenshot of the output

Question 10:
WAP to find an item from a list and replace with user entered item

Code:
L1=[16, 21, 45, 10, 19]
print("Original List=",L1)
item1=int(input("Enter item to be replaced?"))
item2=int(input("With which item?"))
Page 4 of 5
index=0
for i in range(len(L1)):
if L1[i]==item1:
L1[i]=item2
print("List after change=",L1)
break
else:
print("Item is not present in the list")

Output:
Paste Screenshot of the output

Page 5 of 5

You might also like