1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vinil7 [7]
3 years ago
9

Write a program palindrome.py that prompts for a sequence of words or numbers on a single line and checks if the entries are pal

indromes or not. A word or a number is a palindrome if it remains unchanged when reversed. e.g. rotor is a palindrome; but python is not a palindrome. e.g. 737 is a palindrome; but 110 is not a palindrome. The program receives the sequence as input and returns True if an entry is a palindrome or False if an entry is not a palindrome. Print the boolean value on one line. Print the palindromes count on the next line.
Computers and Technology
1 answer:
olya-2409 [2.1K]3 years ago
3 0

Answer:

Explanation:

The program first asks the user for the sequence of words. Then it splits the sequence into an array of words. Then it loops through the array checking each word to see if it is a palindrome. If it is it prints the word, the boolean value, and adds 1 to the palindrome_count variable. Otherwise it prints the word, false, and moves on to the next word in the list. Finally, it prints out the total value of palindrome_count.

word = input("Enter sequence of words: ")

word_list = word.split(' ')

print(word_list)

palindrome_count = 0

for word in word_list:

   print('\n\n')

   reverse = word[::-1]

   if word == reverse:

       print(word, end='\n')

       print(True, end="\n")

       palindrome_count += 1

   else:

       print(word, end='\n')

       print(False, end='\n')

print("\n\nNumber of Palindromes in Sequence: " + str(palindrome_count))

You might be interested in
Why are medical coders using encoded software
EastWind [94]
To keep the medical records confidential otherwise, hackers would take advantage of them and sell them to the highest bidder 
3 0
3 years ago
Which method is useful for dimensionality reduction especially for small data-sets?
Anna [14]
Independent Component Analysis (ICA) is based on information-theory and is also one of the most widely used dimensionality reduction techniques.
8 0
2 years ago
The natural functions of Earth seem all _____ in one way or another.
Sonja [21]
Would it be Similar ?
4 0
3 years ago
A shuffle of two strings X and Y is formed by interspersing the characters into a new string, keeping the characters of X and Y
levacccp [35]

Shuffle (A[1..m], B[1..n], C[1..m+n]):

Shuf[0, 0] ← True

for j ← 1 to n

Shuf[0, j] ← Shuf[0, j − 1] ∧ (B[j] = C[j])

for i ← 1 to n

Shuf[i, 0] ← Shuf[i − 1, 0] ∧ (A[i] = B[i])

for j ← 1 to n

Shuf[i, j] ← False

if A[i] = C[i + j]

Shuf[i, j] ← Shuf[i, j] ∨ Shuf[i − 1, j]

if B[i] = C[i + j]

Shuf[i, j] ← Shuf[i, j] ∨ Shuf[i, j − 1]

return Shuf[m, n]

The algorithm runs in O(mn) time.

3 0
3 years ago
Cybercrime has a serious economic impact on national and global economies that costs the _____ of its GDP every year.
maks197457 [2]

Answer:

World at least 1 percent

Explanation:

Cybercrime are crimes that focuses on networks of computers whereby a computer is used to commit the crime or a computer is the target of the crime, with the possible effect of a threat to the security and financial wellbeing of a person, an establishment or country

According to the report by Zhanna Malekos Smith and Eugenia Lostri, 'The Hidden Costs of Cybercrime' the monetary cost of cybercrime which is estimated at $945 billion is <u>a little above 1% of the World's GDP</u> which is around $87.55 trillion.

4 0
3 years ago
Other questions:
  • Common features of a thunderstorm are _____. thunder lightning rain or hail all of the above
    6·2 answers
  • But this time use 16 kib pages instead of 4 kib pages. what would be some of the advantages of having a larger page size? what a
    11·1 answer
  • Write a for loop to verify that your function is correctly returning the expected output for the radius values between 0 and 11.
    14·1 answer
  • Which of the following is the largest unit of information?
    15·2 answers
  • Micro sleep is when you ____.
    11·2 answers
  • Write an expression that executes the loop while the user enters a number greater than or equal to 0.
    9·1 answer
  • Which statements are true? Select 4 options.
    9·1 answer
  • What happens when you create a variable in a video game program?​
    5·1 answer
  • What type of malicious software technology is used to download and install software without the user's interaction?
    12·1 answer
  • Does the source MAC address match your PC interface?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!