0% found this document useful (0 votes)
9 views

PIKA

Uploaded by

Evil Immortal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

PIKA

Uploaded by

Evil Immortal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

KANHA MAKHAN

PUBLIC SCHOOL

ARTIFICIAL INTELLIGENCE (417)


REPORT FILE

SUBMITTED TO : MR. VISHAL PATHAK


PREPARED BY : MDIPIKA
DIPIKA SOLANKI
CLASS : 10th–M
CERTIFICATE

THIS IS TO CERTIFY THAT THIS REPORT FILE IS


THE BONAFIDE THE WORK 0F MISS. MAHAK
DIPIKA SHARMA OF CLASS 10thM , ROLL NO. 11 IN
THE SESSION 2024-25 OF KANHA MAKHAN
PUBLIC SCHOOL, MATHURA CARRIED OUT IN THE
SCHOOL UNDER MY SUPERVISION.

TEACHER SIGNATURE:
AKNOWLEDGEMENT

I AM THANKFUL TO MY ARTIFICIAL INTELLIGENCE


TEACHER FOR GUIDANCE AND SUPPORT . I ALSO
THANK MY PRINCIPAL MR . PRAMOD SHARMA . I
WOULD ALSO LIKE TO THANK MY PARENTS AND
MY CLASSMATES FOR ENCOURAGING ME DURING
THE COURSE OF THIS REPORT FILE . FINALLY I
WOULD LIKE TO THANK CBSE FOR GIVING ME
THIS OPPORTUNITY TO UNDERTAKE THIS
PRACTICAL WORK .
PROBLEM 1 : Write a program to accept
numbers till the user entered zero and then find
their average.

CODING :
sum = 0

count = 0

print("Enter numbers (enter 0 to stop):")

while True:

num = int(input())

if num == 0:

break

sum += num

count += 1

if count > 0:

avg = sum / count

print("Average:", avg)

else:

print("No numbers entered.")

OUTPUT :

Enter numbers (enter 0 to stop):

15

Average: 10.0
PROBLEM 2 : write a program to check whether
a number is palindrome or not.

CODING :

num=int(input("Enter a number:"))

temp=num

rev=0

while (num>0):

dig=num%10

rev=rev*10+dig

num=num//10

if(temp==rev):

print("The number is a palindrome!")

else:

print("The number is not /palindrome!")

OUTPUT :

Enter the number : 1002001

The number is a palindrome .


PROBLEM 3 : write a program to obtain
principal amount, rate of interest and time from
the user and compute simple interest.

CODING :
p = float(input("Enter Principal amount: "))

r = float(input("Enter Rate of interest:"))

t = float(input ("Enter time :"))

si =p*r*t/100

print("Simple interest =",si)

OUTPUT :

Enter Principal amount: 9000

Enter Rate of interest:15

Enter time :5

Simple interest = 6750.0


PROBLEM 4 : write a program to display the
sum of even numbers upto number n entered by
the user.

CODING:

num = int(input('Enter a number: '))

sum = 0

i=0

while i<= num:

if i % 2 == 0:

sum+=i

i+=1

print("Sum of all the even numbers is",sum)

OUTPUT:

Enter a number: 64

Sum of all the even numbers is 1056


PROBLEM 10 : write a programto calculate the
sum of numbers from 1 to100 using a while loop.

CODING :
i=0

sum = 0

while i<=100:

sum = sum + i

i = i+1

print("Sum = ",sum)

OUTPUT :

Sum = 5050
PROBLRM 5 : write a program to swap two
numbers without using the third variable

CODING :
x = int(input("Enter the value of x:"))

y = int(input("Enter the value of y:"))

print("Numbers before swaping: %d %d"%(x,y))

x = x+y

y = x-y

x = x-y

print("Numbers after swaping: %d %d"%(x,y))

OUTPUT:

Enter the value of x:535

Enter the value of y:639

Numbers before swaping: 535 639

Numbers after swaping: 639 535


PROGRAM 6 : write a program to print the table
of any number by using while loop.

CODING :
n = int(input("Enter any Number :"))

i=1

while i< 11:

value = n * i

print(n," * ",i," = ",value)

i=i+1

OUTPUT:

Enter any Number :5

5 * 1 = 5

5 * 2 = 10

5 * 3 = 15

5 * 4 = 20

5 * 5 = 25

5 * 6 = 30

5 * 7 = 35

5 * 8 = 40

5 * 9 = 45

5 * 10 = 50
PROBLRM 7 : write a progam to print whether a
given character is an uppercase or lowercase
character or digit or any other character.

CODING :
char = input("Enter a character: ")

if char.isupper():

print("Uppercase letter")

elifchar.islower():

print("Lowercase letter")

elifchar.isdigit():

print("Digit")

else:

print("Other character")

OUTPUT :

Enter a character: 63445

Digit

Enter a character: HELLO

Uppercase letter

Enter a character: hello

Lowercase letter
PROBLEM 9 : write a program to count the
number of vowels in a string using for loop.

CODING:
str = input("Please enter a string as you wish :")

vowels = 0

for i in str :

if i in 'aeiouAEIOU':

vowels += 1

print("The number of vowels:",vowels)

OUTPUT :

Please enter a string as you wish :

GOOD MORNING

The number of vowels: 4


PROBLEM 15 : write a program to take the
input of a number ‘n’ and then find and display its
factorial (n!).

(For Ex. 5!=5*4*3*2*1 i.e.120.)

CODING :
n = int(input("enter the number:"))

factorial = 1

if n < 0 :

print("Factorial does not exist for negative numbers")

elif n == 0:

print("The factorial of 0 is 1")

else:

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

factorial = factorial*i

print("The factorial of ",n," is", factorial)

OUTPUT :

enter the number:5

The factorial of 5 is 120


PROBLEM 14 : write a program to print the
following pattern.

*
**
***
****
*****

CODING :
rows = int(input("Enter number of rows: "))

for i in range(rows):

for j in range(i+1):

print("* ", end="")

print()

OUTPUT :

Enter number of rows: 5

**

***

****

*****
PROBLEM 8 : write a program to display all
numbers within a range except the prime numbers.

CODING :
start_range = int(input("Enter the start of the range: "))

end_range = int(input("Enter the end of the range: "))

print("Non-prime numbers in the range:")

for num in range(start_range, end_range + 1):

if num <= 1:

print(num)

else:

is_prime = True

for i in range(2, int(num**0.5) + 1):

if num % i == 0:

is_prime = False

if not is_prime:

print(num)

OUTPUT :

Enter the start of the range: 15

Enter the end of the range: 20

Non-prime numbers in the range

15 16 18 20
PROBLEM 12 :write a program to input two
numbers and swap both the numbers by using third
number.

CODING :

x = int(input ("Enter value of x:"))

y = int(input("Enter value of y:"))

temp = x

x=y

y = temp

print("Value of x:",x)

print("Value of y:",y)

OUTPUT:

Enter value of x:564

Enter value of y:876

Value of x: 876

Value of y: 564
PROBLEM 13: write a program to print the
following pattern .

4321

432

43

CODING :
for i in range(1, 5):

for j in range(4, i - 1, -1):

print(j, end="")

print()

OUTPUT :

4321

432

43

4
PROBLEM 11 : write a program to calculate
the area of circle, rectangle and triangle
depending upon user choice. The choice should be
entered by the user in the form of a menu. Wrong
choice should be addressed.

CODING :
while True:

print("\nMenu:")

print("1. Circle")

print("2. Rectangle")

print("3. Triangle")

print("4. Exit")

choice = input("Choose an option (1-4): ")

if choice == '1':

radius = float(input("Enter radius: "))

area = 3.14 * radius ** 2

print(f"Area of Circle: {area:.2f}")

elif choice == '2':

length = float(input("Enter length: "))

width = float(input("Enter width: "))

area = length * width

print(f"Area of Rectangle: {area:.2f}")

elif choice == '3':

base = float(input("Enter base: "))

height = float(input("Enter height: "))


area = 0.5 * base * height

print(f"Area of Triangle: {area:.2f}")

elif choice == '4':

print("Exiting.")

break

else:

print("Invalid choice! Please try again.")

OUTPUT :
Menu:

1. Circle

2. Rectangle

3. Triangle

4. Exit

Choose an option (1-4): 1

Enter radius: 4

Area of Circle: 50.24

Menu:

1. Circle

2. Rectangle

3. Triangle

4. Exit

Choose an option (1-4): 2

Enter length: 25

Enter width: 15

Area of Rectangle: 375.00


Menu:

1. Circle

2. Rectangle

3. Triangle

4. Exit

Choose an option (1-4): 3

Enter base: 15

Enter height: 20

Area of Triangle: 150.00

Menu:

1. Circle

2. Rectangle

3. Triangle

4. Exit

Choose an option (1-4): 0

Invalid choice! Please try again.

You might also like