Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!