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
Consider the series of alternating 1s and 0s 1 0 1 0 1 0 1 0 1 0 ...... The user will enter a number n . And you have to output
Vika [28.1K]

Answer:

# user is prompted to enter the value of n

n = int(input("Enter your number: "))

# if statement to check if n > 0

if (n > 0):

   # for-loop to loop through the value of n

   for digit in range(1, (n+1)):

       # if digit is odd, print 1

       if((digit % 2) == 1):

           print("1", end=" ")

       # else if digit is even print 0

       else:

           print("0", end=" ")

Explanation:

The code is written in Python and is well commented.

A sample output of the code execution is attached.

8 0
3 years ago
What makes a GOOD algorithm choose?
julia-pushkina [17]

Answer: I'd go with Efficiency and Correct.

7 0
2 years ago
Which of the following statements is False? A package passes through several MAC addresses to reach an IP address. IP addresses
oksano4ka [1.4K]
<span>The MAC address marks the final destination of the frames.

It marks the next destination.</span>
5 0
3 years ago
How many times will an infinite loop repeat?
ExtremeBDS [4]

Answer:

The infinite loop is suppose to go on and on it never ends. My best guess is the third one.

7 0
3 years ago
How to make a telescope​
agasfer [191]

Answer:

sorry if this is really long  

1

Gather all your materials. You'll need a piece of corrugated paper that is about 24 inches in length (this is a ridge material, easily available from paper stores or craft stores). You'll need two magnifying glasses that are NOT the same size. You will also need strong glue, scissors, and a pencil.[1]  

If the magnifying glasses are the same size, the telescope won't work.

2

Hold one magnifying glass (the bigger one) between you and the paper. The image of the print will look blurry. Place the second magnifying glass between your eye and the first magnifying glass.[2]

3

Move the second glass forward or backward until the print comes into sharp focus. You will notice that the print appears larger and upside down.

4

Wrap the paper around one of the magnifying glasses. Mark the diameter on the paper with the pencil. Make sure that it is pulled tight.[3]

5

Measure along the edge of the paper from the first mark. You will need to measure about 1 1/2 inches from the mark. This will create the extra length to glue around the magnifying glass.

6

Cut down the marked line on the paper to the other side. You should be cutting across the width of it (don't cut lengthwise). The paper should be about 24 inches in length on one side. Cut a slot in the cardboard tube near the front opening about an inch (2.5 cm) away. Do not cut all the way through the tube. The slot should be able to hold the large magnifying glass.

7

Cut a second slot in the tube the same distance from the first slot as was written down between the two glasses. This is where the second magnifying glass will go.  

You should now have two lengths of corrugated paper. One piece should be slightly larger than the other.

8

Place the two magnifying glasses in their slots (big one at front, little one at back) and tape them in with the duct tape. Leave about 0.5 - 1 inch (1 - 2 cm) of tube behind the small magnifying glass and cut off any excess tube remaining.

9

Glue first length of paper around one of the magnifying glasses. You'll need to glue the edges of the paper together as well, since you've left about 1 1/2 inches of paper.

10

Make the second magnifying glass tube. This one will need to be slightly bigger than the first one. Not too much bigger, only so that the first will fit into the second one.

11

Slot the 1st tube into the 2nd. You can now use this telescope for looking at things farther away, although it will be difficult to view the stars clearly. This type of telescope is really good for viewing the moon.  

The images will be upside down, since astronomers don't care about up and down in space (there is no up or down in space, after all). if you wish to align the image with gravity, you can use two prisms aligned in an "N" shape to correct the image, but you will have to re-position the lenses.

youll need:

Two magnifying glasses, not the same size  

A roll of corrugated paper  

strong glue  

scissors  

a pencil  

For the lens telescope:  

Two lenses: concave-convex lens with a diameter of 49 mm, and a focal length of 1,350 mm and a plano-concave lens with a diameter of 49 mm, and a focal length of 152 mm  

A mailing tube with inner and outer tubes  

Coping saw  

Box cutter  

Drill or electrician's punch  

Glue

5 0
3 years ago
Other questions:
  • What does the picture indicate on the famous book “Dawn of the century”?​
    10·1 answer
  • A subclass of Value, LargerValue, is defined with a getValue method that returns twice the value of the parent. Which line is th
    13·1 answer
  • Each TextField has a text property that's returned by its textProperty method as a StringProperty. The StringProperty method ___
    12·1 answer
  • Write a Python function called simulate_observations. It should take no arguments, and it should return an array of 7 numbers. E
    7·1 answer
  • The ______ manages the hardware components including the cpu, memory storage, and peripheral devices. options operating system d
    9·1 answer
  • Select the statements that identify benefits of programming design. Choose all that apply. It ensures that programmers working o
    8·1 answer
  • This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balance
    5·1 answer
  • What would a digitizing application create?
    13·2 answers
  • Imagine that you are preparing a multimedia presentation. What are the four things you need to consider when getting started?
    14·2 answers
  • (1) Experiment Purpose
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!