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
A picture drawn in 3 d is called?​
Varvara68 [4.7K]

Answer:

autostereogram

Explanation:

that^

6 0
3 years ago
Read 2 more answers
A department manager would like to choose an access control model in which the owner of a resource decides who may modify permis
Hoochie [10]

Answer: Discretionary access control (DAC)

Explanation: Discretionary access control is the control system that is imposed over the information system. The information systems contains different objects and subjects that gets the permission to do the operations.

The operation which the components can do are sharing the data to other object or subjects, privilege providence, change in the rules for the access, security entities getting changed etc.

4 0
3 years ago
What specific type of DNS query instructs a DNS server to process the query until the server replies with an address that satisf
Kaylis [27]
Unsure how it is to be answered
8 0
3 years ago
Public-key cryptography (a form of asymmetric cryptography) is an encryption method that's widely used because: 1) it is computa
rosijanka [135]

Answer:

C.

Explanation:

7 0
3 years ago
Write a Java program to accept an item's name and price from the user and output them to the console
Anit [1.1K]

Answer:

// program in java.

// package

import java.util.*;

// class definition

class Main

{// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // scanner object to read inputs

Scanner scr=new Scanner(System.in);

 // variables

String name;

   double price;

   System.out.print("Enter item's name: ");

   // read item's name

   name = scr.next();

   System.out.print("Enter item's price: ");

   // read item's price

   price= scr.nextDouble();

   // print name

   System.out.println("name of item is:"+name);

   // print price

   System.out.println("price of item is:"+price);

   }catch(Exception ex){

       return;}

}

}

Explanation:

Read name & price of item from user and assign it to variables "name" & "price" respectively with scanner object.Then print the name and price of item .

Output:

Enter item's name: Apple                                                                                                  

Enter item's price: 100                                                                                                    

name of item is:Apple                                                                                                      

price of item is:100.0

6 0
3 years ago
Other questions:
  • Is a term used to define those providers or hospitals that have the capabilities and processes in place to be actively use certi
    15·1 answer
  • What is some effective writing techniques?
    7·1 answer
  • Pressing the e key while in edit mode will exit the interaction mode<br><br> true<br><br> false
    7·1 answer
  • Which of the following statements is true with regards to satellite Internet access?
    13·2 answers
  • Which is worse: Fast charging (Due to heat) or unplugging before reaching full capacity (On a normal charge)?
    9·1 answer
  • Why would you use quotation marks in a search string when conducting an internet search?
    12·1 answer
  • How do the companies gather data to determine common passwords?
    13·1 answer
  • What is a common translator?​
    9·1 answer
  • What caused accident? into passive voice​
    13·1 answer
  • Distinguished between
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!