0% found this document useful (0 votes)
44 views26 pages

Practical File 2025-2026

The document outlines a Python program to determine if a given string is a palindrome. It includes an algorithm with steps for execution and a sample program code. The program checks the string and outputs whether it is a palindrome or not based on user input.
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)
44 views26 pages

Practical File 2025-2026

The document outlines a Python program to determine if a given string is a palindrome. It includes an algorithm with steps for execution and a sample program code. The program checks the string and outputs whether it is a palindrome or not based on user input.
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
You are on page 1/ 26

1

1
2

2
3

3
4

4
5

5
6

STRING PALINDROME
Write a program in Python to find given string is palindrome or not
AIM:
To check whether the given string is palindrome or not.
ALGORITHM:
Step 1: Start the program execution Step 2: Read the value of s
Step 3: Call the function isPalindrome(s)
Step 4: Check for loop, if the condition is true go to step 5 else go to step 7
Step 5: Check if str[i]!=str[len(str)-i-1] , if the condition is true go to step 7 else go
to step 5
Step 6: Return False to ans , then go to step 8
Step 7: Return True to ans , then go to step 8
Step 8: Check if(ans) , if the condition is true go to step 9 else go to step 10
Step 9: Print “The given string is Palindrome”
Step 10: Print “The given string is not a Palindrome”
Step 11: Stop the program execution

PROGRAM:
def isPalindrome(str):
for i in range(0, int(len(str)/2)):
if str[i]!=str[len(str)-i-1]:
return False
else:
return True
s=input("Enter string:")
ans = isPalindrome(s)
if (ans):
print("The given string is Palindrome")
else:
print("The given string is not a Palindrome")

OUTPUT:
Enter string: madam
The given string is Palindrome Enter string: computer
The given string is not a Palindrome

6
7

7
8

8
9

9
10
10

11
11------ PROGRAM pdf

12
12

13
13---------Pdf

14

14
15

15
16

16
17

17
18

18
19
19

20
20

21
22
21

23
24
25
26

You might also like