0% found this document useful (0 votes)
98 views18 pages

AI Project File: Programming Tasks

This document is a project file for an Artificial Intelligence course submitted by Yash Ahuja to Mr. Kumar Gaurav at Delhi Public School, Ranipur for the session 2024-25. It includes a series of programming assignments that cover various basic programming concepts such as character checking, arithmetic operations, and list manipulations. Each assignment is presented with a problem statement, corresponding Python code, and expected output.

Uploaded by

gamerak635
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)
98 views18 pages

AI Project File: Programming Tasks

This document is a project file for an Artificial Intelligence course submitted by Yash Ahuja to Mr. Kumar Gaurav at Delhi Public School, Ranipur for the session 2024-25. It includes a series of programming assignments that cover various basic programming concepts such as character checking, arithmetic operations, and list manipulations. Each assignment is presented with a problem statement, corresponding Python code, and expected output.

Uploaded by

gamerak635
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

DELHI PUBLIC SCHOOL,RANIPUR

SESSION(2024-25)

ARTIFICIAL INTELLIGENCE PROJECT FILE

SUBMITTED BY: SUBMITTED TO:


YASH AHUJA MR.KUMAR GAURAV
IX-I DEPARTMENT OF
ROLL NO.38 COMPUTER
s.no. PROGRAM Pg.
. WAP that accepts a character from the user and finds whether the entered character is vowel or consonant
1 1

Write a program to accept three numbers from the user and find their average.
2 2
Write a program to swap values of two integer variables using a third variable
3 3
Write a program that accepts a number from the user and checks whether the entered number is divisible by 5 or not.
4 4
Write a program to accept length,breadth from user, display the area and perimeter of a rectangle
5 5
. To calculate Simple Interest if the principal_amount = 2000, rate_of_interest = 4.5, time = 10 years
6 6
Write a program that accepts total sales from the user and calculate the discount as per the following criteria : If sales>= 10000 then discount = 10
7 % If sales 7
Write a program to accept three integer values from the user and display the greatest value
8 8
Write a program to display the sum of the first 10 natural numbers
9 9
WAP to sum of all Program to calculate and print the sums of even and odd integers of the first n natural number.
10 10
. WAP to check the Armstrong number given by the user
11 11
Create a list of first 10 even numbers, add 1 to each list item and print the final list.
12 12
. Create a list, myList=[10,20,30,40]. Add the elements [14,15,12] using the extend method.
13 13

. WAP to print the following pattern using concept of nested loop :


14 14
1

12

123

1234

12345

. WAP to print the following pattern using concept of nested loop :


15 15
*****

****

***

**

*
1. WAP that accepts a character from the user and finds whether the entered character is vowel or consonant.

2. Write a program to accept three numbers from the user and find their average.

3. Write a program to swap values of two integer variables using a third variable.

4. Write a program that accepts a number from the user and checks whether the entered number is divisible by 5 or not.

5. Write a program to accept length and breadth from the user and display the area and perimeter of a rectangle.

6. To calculate Simple Interest if the principal_amount = 2000, rate_of_interest = 4.5, time = 10 years

7. Write a program that accepts total sales from the user and calculate the discount as per the following criteria : If sales>=
10000 then discount = 10 % If sales

8. Write a program to accept three integer values from the user and display the greatest value.

9. Write a program to display the sum of the first 10 natural numbers.

10. WAP to sum of all Program to calculate and print the sums of even and odd integers of the first n natural number.

11. WAP to check the Armstrong number given by the user

12. Create a list of first 10 even numbers, add 1 to each list item and print the final list.

13. Create a list, myList=[10,20,30,40]. Add the elements [14,15,12] using the extend method.

14. WAP to print the following pattern using concept of nested loop :
1

12

123

1234

12345

15. WAP to print the following pattern using concept of nested loop :
*****

****

***

**

*
1 WAP that accepts a character from the user and finds whether the entered character is vowel or consonant.

PROGRAM:

n=input(“enter alphabet:”)

if(n==”a” or n==”e” or n==”i” or n==”o” or n==”u”):

print(“Alphabet is vowel”)

else:

print(“Alphabet is consonant”)

output:

1
2 Write a program to accept three numbers from the user and find their average.

PROGRAM:

a=int(input(“enter number:”))

b=int(input(“enter number 2:”))

c=int(input(“enter number 3:”))

average=(a+b+c)/3

print(“average:”,average)

OUTPUT:

2
3. Write a program to swap values of two integer variables using a third variable

PROGRAM:

a=int(input(“enter a: ”))

b=int(input(“enter b: ”))

print(“Earlier value of a____”,a)

print(“Earlier value of b_____”,b)

c=a

a=b

b=c

print(“Swapped value of a_____: “,a)

print(“Swapped value of b_____: “,b)

OUTPUT:

3
4 Write a program that accepts a number from the user and checks whether the entered number is
divisible by 5 or not.

PROGRAM:

n=int(input(“enter number”))

if(n%5==0):

print(“number is divisible by 5”)

else:

print(“number is not divisible by 5”)

OUTPUT:

4
5 Write a program to accept length and breadth from the user and display the area and perimeter of a
rectangle.

PROGRAM:

a=int(input(“enter length”))

b=int(input(“enter breadth”))

perimeter=2*(a+b)

area=(a*b)

print(“area:”,area)

print(“perimeter:”,perimeter)

OUTPUT:

5
6 To calculate Simple Interest if the principal_amount = 2000, rate_of_interest = 4.5, time = 10 years

PROGRAM:

principal_amount=2000

rate_of_interest=4.5

time=10

simple_interest=(principal_amount*rate_of_interest*time)/100

print(“simple interest:”,simple_interest)

OUTPUT:

6
7 Write a program that accepts total sales from the user and calculate the discount as per the following
criteria : If sales>= 10000 then discount = 10 % If sales<10000 then discount=5%

PROGRAM:

sales=int(input(“enter sales:”))

if(sales >=10000):

discount=(10/100)*sales

else:

discount=(5/100)*sales

print(“discount: “,discount)

OUTPUT:

7
8 Write a program to accept three integer values from the user and display the greatest value.

PROGRAM:

a=int(input(“enter a:”))

b=int(input(“enter b:”))

c=int(input(“enter c:”))

if(a >b);

if(a >c):

print(“a is greatest”)

else:

print(“c is greatest”)

else:

if(b >a):

if(b >c):

print(“b is greatest”)

else:

print(“c is greatest”)

OUTPUT:
9 Write a program to display the sum of the first 10 natural numbers.

PROGRAM:

n=1

sum=0

while n<11:

sum+=n

n+=1

print(sum)

OUTPUT:

9
10 WAP to sum of all Program to calculate and print the sums of even and odd integers of the first n
natural number.

PROGRAM:

n=int(input(“Enter the value of n : “))

sume=0

sumo=0

for i in range(1,n+1):

if i%2==0:

sume+=i

else:

sumo+=i

print(“sum of even numbers = “,sume)

print(sum of odd numbers = “,sumo)

OUTPUT:

10
11 WAP to check the Armstrong number given by the user

PROGRAM:

a=int(input(“enter any number:”))

b=a//100

c=a//10

d=c%10

e=a%10

f=(b**3+d**3+e**3)

if(f==a):

print(“THE NUMBER IS AN ARMSTRONG NUMBER”)

else:

print(“THE NUMBER IS NOT AN ARMSTRONG NUMBER”)

OUTPUT:

11
12.Create a list of first 10 even numbers, add 1 to each list item and print the final list.

PROGRAM:

list=[2,4,6,8,10,12,14,18,20]

new_list= [num + 1 for num in list]

print(new_list)

OUTPUT:

12
13 Create a list, myList=[10,20,30,40]. Add the elements [14,15,12] using the extend method.

PROGRAM:

myList=[10,20,30,40]

myList.extend([14,15,12])

print(myList)

OUTPUT:

13
14.WAP to print the following pattern using concept of nested loop :

12

123

1234

12345

PROGRAM:

for i in range(1,6):

for j in range(1,i+1):

print(j,end=””)

print()

OUTPUT:

14
15 WAP to print the following pattern using concept of nested loop :

*****

****

***

**

PROGRAM:

for i in range(5,0,-1):
for b in range (i,0,-1):
print("*",end="")
print()
for i in range (5,0,-1):

for b in range (1,0,-1):

print(“*”,end=””)

print()

OUTPUT:

15

You might also like