Write a program that uses a stack to test input strings to determine whether they are palindromes. A palindrome is a sequence of characters that reads the same as the sequence in reverse; for example, noon.

Answers

Answer 1

Answer:

Here the code is given as follows,

Explanation:

def isPalindrome(x):

   stack = []

   #for strings with even length

   if len(x)%2==0:

       for i in range(0,len(x)):

           if i<int(len(x)/2):

               stack.append(x[i])

           elif stack.pop()!=x[i]:

               return False

       if len(stack)>0:

           return false

       return True

   #for strings with odd length    

   else:

       for i in range(0,len(x)):

           if i==int(len(x)/2):

               continue

           elif i<int(len(x)/2):

               stack.append(x[i])

           elif stack.pop()!=x[i]:

               return False

       if len(stack)>0:

           return false

       return True  

def main():  

   while True:  

       string = input("Enter a string or Return to quit: ")  

       if string == "":  

           break  

       elif isPalindrome(string):  

           print("It's a palindrome")  

       else:  

           print("It's not a palindrome")  

if __name__ == '__main__':  

   main()

Write A Program That Uses A Stack To Test Input Strings To Determine Whether They Are Palindromes. A
Write A Program That Uses A Stack To Test Input Strings To Determine Whether They Are Palindromes. A

Related Questions

the id selector uses the id attribute of an html element to select a specific element give Example ?​

Answers

Answer:

The id selector selects a particular html element

Explanation:

The id selector is uses the id attribute to select a specific html element. For example, if we have a particular header which is an html element and we want to give it a particular background color, we use the id selector and give it an id attribute in the CSS file. An example of an html header with id = 'blue' is shown below. The style sheet is an internal style sheet.

!doctype html

<html>

<head>

<title>Test</title>

<style>

#blue { background-color: blue;

}

</style>

</head>

<body>

<h1 id = 'blue'>Our holiday</h1>

<p>This is the weekend</p>

</body>

</html>

Write a program that removes all non-alpha characters from the given input. Ex: If the input is: -Hello, 1 world$! the output is: Helloworld

Also, this needs to be answered by 11:59 tonight.

Answers

Answer:

Explanation:

The following code is written in Python. It is a function that takes in a string as a parameter, loops through the string and checks if each character is an alpha char. If it is, then it adds it to an output variable and when it is done looping it prints the output variable. A test case has been provided and the output can be seen in the attached image below.

def checkLetters(str):

   output = ''

   for char in str:

       if char.isalpha() == True:

           output += char

   return output

If you fail a course as a MAIN (residency) course, you can repeat that course as either a MAIN (residency) or an online (IG or IIG) course.
A. True
B. False

Answers

it depends on where you are taking your courses. In most cases the answer would be true

In confirmatory visualization Group of answer choices Users expect to see a certain pattern in the data Users confirm the quality of data visualization Users don't know what they are looking for Users typically look for anomaly in the data

Answers

Answer: Users expect to see a certain pattern in the data

Explanation:

Confirmatory Data Analysis occurs when the evidence is being evaluated through the use of traditional statistical tools like confidence, significance, and inference.

In this case, there's an hypothesis and the aim is to determine if the hypothesis is true. In this case, we want to know if a particular pattern on the data visualization conforms to what we have.

What order? (function templates) Define a generic function called CheckOrder() that checks if four items are in ascending, neither, or descending order. The function should return -1 if the items are in ascending order, 0 if the items are unordered, and 1 if the items are in descending order. The program reads four items from input and outputs if the items are ordered. The items can be different types, including integers, strings, characters, or doubles. Ex. If the input is:

Answers

Answer:

Explanation:

The following code was written in Java and creates the generic class to allow you to compare any type of data structure. Three different test cases were used using both integers and strings. The first is an ascending list of integers, the second is a descending list of integers, and the third is an unordered list of strings. The output can be seen in the attached image below.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Order: " + checkOrder(10, 22, 51, 53));

       System.out.println("Order: " + checkOrder(55, 44, 33, 22));

       System.out.println("Order: " + checkOrder("John", " Gabriel", "Daniela", "Zendaya"));

   }

   public static <E extends Comparable<E>> int checkOrder(E var1, E var2, E var3, E var4) {

       E prevVar = var1;

       if (var2.compareTo(prevVar) > 0) {

           prevVar = var2;

       } else {

           if (var3.compareTo(prevVar) < 0) {

               prevVar = var3;

           } else {

               return 0;

           }

           if (var4.compareTo(prevVar) < 0) {

               return 1;

           }  else {

               return 0;

           }

       }

       if (var3.compareTo(prevVar) > 0) {

           prevVar = var3;

       }

       if (var4.compareTo(prevVar) > 0) {

           return -1;

       }

       return 0;

   }

}

fill in the blanks Pasaline could ----- and ------- very easily.​

Answers

Answer:

Hot you too friend's house and be safe and have a great time to take care of the following is not a characteristic it was a circle whose equation o
Other Questions
Pls help me someone this is annoying me On January 1, a machine with a useful life of 5 years and a salvage value of $15000 was purchased for $115000. What is the depreciation expense for year 2 under straight-line depreciation 2. the amount of a good or service a producer wants to sell(10 Points)demandsupplyscarcity Hey there I need some assistance need on this problem. What do I mean by checkpoints and how am I supposed to find the y-intercept and the slope from the given values? Find the equation of the line thatis perpendicular to y = -4x + 3and contains the point (8, 1). pls help with this question will mark brainliest :)) Which materials come together to form plaque? Select three options.salivamucusbacteriatoothpastefood particles How does the Appalachian Mountains important to the US development how do you calculate voltage drop W=VI. Make V the subject of formula what is the comparison of handsome the Barnes family drove 140 miles the first day and 220 miles on the second day. If they drove about 60 miles per hour, approximately how many hours did they drive? Jessica purchases a kayak in Florida, where the state sales taxes are 6%. She paid $72 in sales tax. What was the retail price of the kayak? In a science museum, a 130 kg brass pendulum bob swings at the end of a 14.4 m -long wire. The pendulum is started at exactly 8:00 a.m. every morning by pulling it 1.7 m to the side and releasing it. Because of its compact shape and smooth surface, the pendulum's damping constant is only 0.010kg/s. You may want to review (Pages 405 - 407) . Part A At exactly 12:00 noon, how many oscillations will the pendulum have completed Specialties including therapists, athletic trainers, and dietitians fall under the umbrella title of what? New educational study has proven that the practice of writing, erasing, and rewriting improves students' ability to process information, leading parents to steer away from pen use in favor of pencils.a. Trueb. False The given equation has been solved in the table. Step Statement 1 1 7n + 11 = -10 2. -7n + 11 11 = -10 11 3 -7n = -21 4 = = =21 .In -7 -21 __7 5 n = 3 Use the table to complete each statement. In step 2, the In step 4, the property of equality was applied. property of equality was applied. Please help me out with these questions : the base of a right prism is an equilateral triangle each of whose sides measures 4cm.the altitude of the prism measures 5cm.Find the volume of the prism A family eats out at a restaurant and the total for their meals is $73.89. They also pay sales tax of 5.8% and leave a tip for their server. If the family leaves a total of $93, which of the following might be a description of the service they received?a.They left a 10% tip, so the service was probably below average.b.They left a 15% tip, so the service was probably average.c.They left a 20% tip, so the service was probably above average.d.They left a 25% tip, so the service was probably outstanding.