0% found this document useful (0 votes)
13 views3 pages

20 Python Programs for AI Class 10

This document contains a practical file for Class 10 Artificial Intelligence, featuring 20 Python programs. Each program demonstrates basic programming concepts such as input/output, arithmetic operations, control structures, and data structures. The programs range from simple tasks like printing 'Hello World' to more complex functions like generating a Fibonacci series and checking for palindromes.

Uploaded by

a854282kagus
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)
13 views3 pages

20 Python Programs for AI Class 10

This document contains a practical file for Class 10 Artificial Intelligence, featuring 20 Python programs. Each program demonstrates basic programming concepts such as input/output, arithmetic operations, control structures, and data structures. The programs range from simple tasks like printing 'Hello World' to more complex functions like generating a Fibonacci series and checking for palindromes.

Uploaded by

a854282kagus
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

ARTIFICIAL INTELLIGENCE (AI)

Class 10 – Practical File

Practical File: 20 Python Programs

Program 1: Print Hello World


print('Hello World')

Program 2: Add Two Numbers


a = 5 b = 3 print(a + b)

Program 3: Check Even or Odd


n = int(input('Enter number: ')) if n % 2 == 0: print('Even') else: print('Odd')

Program 4: Find Largest of Two Numbers


a = int(input()) b = int(input()) print(max(a,b))

Program 5: Find Square of a Number


n = int(input()) print(n*n)

Program 6: Simple Interest


p=1000 r=5 t=2 si=(p*r*t)/100 print(si)

Program 7: Area of Circle


r = float(input()) area = 3.14*r*r print(area)

Program 8: Check Positive or Negative


n=int(input()) if n>0: print('Positive') elif n<0: print('Negative') else: print('Zero')

Program 9: Print First 10 Natural Numbers


for i in range(1,11): print(i)

Program 10: Sum of Natural Numbers


n=10 print(sum(range(1,n+1)))

Program 11: Multiplication Table


n=int(input()) for i in range(1,11): print(n,'x',i,'=',n*i)

Program 12: Factorial of Number


n=5 fact=1 for i in range(1,n+1): fact*=i print(fact)

Program 13: Fibonacci Series


a,b=0,1 for i in range(10): print(a) a,b=b,a+b

Program 14: Reverse a Number


n=123 rev=0 while n>0: rev=rev*10+n%10 n//=10 print(rev)

Program 15: Palindrome Check


s=input() if s==s[::-1]: print('Palindrome') else: print('Not Palindrome')

Program 16: Count Vowels


s=input() v='aeiouAEIOU' count=0 for i in s: if i in v: count+=1 print(count)

Program 17: List Sum


lst=[1,2,3,4] print(sum(lst))

Program 18: Find Maximum in List


lst=[3,7,1,9] print(max(lst))

Program 19: Dictionary Example


d={'a':1,'b':2} print(d)
Program 20: Simple AI Example (Rule Based)
age=int(input()) if age>=18: print('Eligible to Vote') else: print('Not Eligible')

You might also like