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
frozen [14]
3 years ago
12

Your task is to build a palindrome from an input string.A palindrome is a word that readsthe same backward or forward. Your code

will take the first 5 characters of the user input, and create a 9-character palindrome from it.Words shorter than 5 characters will result in a runtime error when you run your code. This is acceptablefor this exercise, however you already know how to validate user input with an IF statement.Some examplesof input words and the resulting palindromes:
Computers and Technology
1 answer:
White raven [17]3 years ago
7 0

Answer:

The program in Python is as follows:

word = input("Word: ")

if len(word) < 5:

   print("At least 5 characters")

else:

   pal = word[0:5]

   word = word[0:4]

   word = word[::-1]

   pal+=word

   print(pal)

Explanation:

This gets the word from the user

word = input("Word: ")

This checks if the length of the word is less than 5.

if len(word) < 5:

If yes, this tells the user that at least 5 characters is needed

   print("At least 5 characters")

If otherwise

else:

This extracts the first 5 characters of the word into variable named pal

   pal = word[0:5]

This extracts the first 5 characters of the word into variable named word

   word = word[0:4]

This reverses variable word

   word = word[::-1]

This concatenates pal and word

   pal+=word

This prints the generated palindrome

   print(pal)

You might be interested in
What is the network id with cidr notation for the ip address 172.16.32.108 with the subnet mask 255.255.255.0?
kow [346]
172.16.32.0/24






-------------------------------
7 0
3 years ago
(Python question)
Law Incorporation [45]

Hey!

---------------------------------------------------

Definition:

A "for loop" is something used for repeating things over a list of items. For instance, a list or a dictionary.

Code:

colors = ["red", "green", "blue"]

for x in colors:

 print(x)

---------------------------------------------------

Definition:

A "while loop" is is something used for carrying out a set of lines that are true.

Code:

n = 1

while i < 4:

 print(n)

 n += 1

---------------------------------------------------

Real-Life Example:

A real-life example would if I was a manager or boss for a company say that everyone was off a certain day. Like, if I said everyone was off for Christmas the 25th. If I had 1000 employees that would take a very long time to send an email to everyone. Instead of sending an email to everyone I can program code that uses "for loops" and "while loops" to create a message and send it to everyone.

---------------------------------------------------

Hope This Helped! Good Luck!

3 0
3 years ago
Read 2 more answers
Explain the quality-improvement process.
Tasya [4]

Answer:

 The quality improvement is the process that involve the complete organization in pursuit of the quality. It basically helps to improve the team knowledge and in decision making by using the validate data.  

The quality improvement is the proactive undertaking of recognizing, breaking down and enhancing existing business forms inside an association for enhancement and to satisfy new portions or guidelines of value.

 The main factors of the quality improvement are:

  • Leadership quality
  • Monitoring various types of systems
  • High availability of resources
  • Adequate infrastructure

3 0
3 years ago
Read 2 more answers
The _____ database structure is more flexible and stores data as well as instructions to manipulate the data.
Talja [164]

Answer:

Databace

Explanation:

5 0
2 years ago
Write an application that uses String method region-Matches to compare two stringsinput by the user. The application should inpu
SOVA2 [1]

Answer:

Explanation:

The following program creates a function called region_Matches that takes in two strings as arguments as well as an int for starting point and an int for amount of characters to compare. Then it compares those characters in each of the words. If they match (ignoring case) then the function outputs True, else it ouputs False. The test cases compare the words "moving" and "loving", the first test case compares the words starting at point 0 which outputs false because m and l are different. Test case 2 ouputs True since it starts at point 1 which is o and o.

class Brainly {

   public static void main(String[] args) {

       String word1 = "moving";

       String word2 = "loving";

       boolean result = region_Matches(word1, word2, 0, 4);

       boolean result2 = region_Matches(word1, word2, 1, 4);

       System.out.println(result);

       System.out.println(result2);

   }

   public static boolean region_Matches(String word1, String word2, int start, int numberOfChars) {

       boolean same = true;

       for (int x = 0; x < numberOfChars; x++) {

           if (Character.toLowerCase(word1.charAt(start + x)) == Character.toLowerCase(word2.charAt(start + x))) {

               continue;

           } else {

               same = false;

               break;

           }

       }

       return same;

   }

}

3 0
2 years ago
Other questions:
  • When you add an rss feed to hootsuite publisher, posts from blogs and websites you designate will be?
    5·1 answer
  • Which of the following is not a job title associated with a career in visual and audio technology? master control operator produ
    9·1 answer
  • What stage of software development incorporates planning to help make changes in the project plan based of reviews
    12·1 answer
  • Which note-taking method quickly captures and organizes information?
    9·2 answers
  • Data cannot be sorted or filterd accuratly if there are ________.
    12·1 answer
  • Assume that the array arr has been defined and initialized with the values {4, 2, 5, 3, 1}. What are the values in the array arr
    15·1 answer
  • The quicksort pivot value should be the key value of an actual data item; this item is called the pivot. True or False?
    11·1 answer
  • What does the top level domain in a url inducate? A. The organization or company that owns the website. B. The organization or c
    6·2 answers
  • 1.The hardware that allows data to be transmitted from a computer along a telephone line to another computer at the other end is
    12·1 answer
  • Explain information technology ?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!