Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python programming Objectives : Practice string indexing. A palindrome is a sequence of characters which reads the same backward or forward. For example, racecar

Using Python programming

Objectives:

Practice string indexing.

A palindrome is a sequence of characters which reads the same backward or forward. For example, racecar is a palindrome. In this assignment, we treat upper- and lowercase letters as being different, i.e., case sensitive.

Write a function to determine whether a given string is a palindrome or not.

The function should be named isPalindrome and be able to accept a string as argument. It returns a Boolean value; True if the passed-in argument is a palindrome, False otherwise. For example, calling isPalindrome("racecar"), users should be able to receive True. However, calling isPpalindrome("Racecar"), users should receive False.

Function specifications:

Function name

isPalindrome

Input parameter

a string

return value

a Boolean value

Testing:

Develop at least 2 test cases, calculate the correct results by hand, and then confirm that your program gives the same results.

To test the correctness of your function, you can make function calls, one for each of your test cases. For example, print(isPalindrome("racecar")) should display True on screen. print(isPalindrome("Racecar")) should display False on screen.

When you are ready to submit, remove all such function calls from your script file. You do not need to submit your test cases.

Code specifications:

You must implement your own algorithm with either a while-loop or for-loop for palindrome determination. You are NOT allowed to use string slicing or reverse method.

Your submitted .py file should contain ONLY your function definition for isPalindrome. Do not include main function or your testing codes.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions