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

Program List

Uploaded by

jerrinantonio
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)
5 views3 pages

Program List

Uploaded by

jerrinantonio
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/ 3

Python Programs list for class X -Artificial Intelligence

1.program to add two numbers by taking input from the user


a=int(input("Enter first number:"))
b=int(input("Enter second number:"))
c=a+b
print("The sum of two numbers=",c)

2.Program to print area of circle or perimeter of circle


r=float(input("Enter the radius of the circle:"))
print("Menu")
print("1.Area of circle")
print("2.Perimeter of circle")
ch=int(input("Enter your choice(1/2):"))
if ch==1:
print("Area of circle=",(3.14*r*r))
else:
print("Perimeter of circle=", (2*3.14*r))

3.program to take input percentage and print grade


per=float(input("Enter percentage: "))
if per>=90:
print('Your grade is A')
elif per>=60 and per<90:
print('Your grade is B')
else:
print('Your grade is C')

4.Program to input age and whether person is a child ,teenager or an adult


age=int(input("Enter the age:"))
if age<13:
print("The person is a child")
elif age>=13 and age<18:
print("The person is a teenager")

else:
print("The person is an adult")

5.program to take input of a string and reverse it


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

6.program to take input of a string and toggle the case of each character
x=input("Enter a string:")
y=x.swapcase()
print("Original string is",x)
print("New string is",y)
7.program to take input of a string and count number of uppercase, lowercase
#digits and special characters in it
x=input("Enter a string:")
u=0
l=0
d=0
s=0
for ch in x:
if ch.isupper():
u+=1
elif ch.islower():
l+=1
elif ch.isdigit():
d=d+1
else:
s=s+1
print("No. of uppercase characters=",u)
print("No. of lowercase characters=",l)
print("No. of digits=",d)
print("No. of special characters=",s)

8.program to take input of a string and check if its a palindrome


x=input("Enter a string:")
y=x[::-1]
if x==y:
print("Entered string is a palindrome")
else:
print("Entered string is not a palindrome")

9.program to take input of a string and find its length.


x=input("Enter a string:")
y=len(x)
print("Length of the entered string is",y)

10.program to take input of two lists and join them


L1=eval(input("Enter first list:"))
L2=eval(input("Enter second list:"))
L3=L1+L2
print("The join of two lists is",L3)

11. program to take input of a list and replicate it thrice


L=eval(input("Enter a list:"))
L1=L*3
print("Replicated list=",L1)

12.program to take input of a number and print its table


n=int(input("Enter a number:"))
for i in range(1,11):
print(n,'X',i,'=',n*i)

13.program to input a number and check if its a palindrome


n=int(input("Enter a number:"))
rev=0
num=n
while n!=0:
d=n%10
rev=rev*10+d
n=n//10
if num==rev:
print("Entered number is a palindrome")
else:
print("Entered number is not a palindrome")

14.program to take input of three numbers and print the maximum number
a=int(input("Enter first number:"))
b=int(input("Enter second number:"))
c=int(input("Enter third number:"))
max=a
if b>max:
max=b
elif c>max:
max=c
print("Maximum number is",max)

15.program to display odd numbers from 1 to 100


for i in range(1,101,2):
print(i)

You might also like