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
Mrac [35]
2 years ago
8

Write a Python function that will accept as input three string values from a user. The method will return to the user a concaten

ation of the string values in reverse order. The function is to be called from the main method.
Computers and Technology
1 answer:
Aleks04 [339]2 years ago
5 0

Answer:

Following are the program in python language

def cat_rev(x,y,z): # function definition  

   x=x[::-1]# reverse the first string  

   y=y[::-1]# reverse the second string  

   z=z[::-1]# reverse the third string  

   z=x+y+z;  #concat the string

   return(z)#return the string

   #main method

s=input("Enter the first string:") #read the first string

r=input("Enter the second string:")#Read the second string  

t=input("Enter the third string:")#Read the third string by user

rev1= cat_rev(s,r ,t ) #function calling

print(rev1)# display reverse string

Output:

Enter the first string:san

Enter the second string:ran

Enter the third string:tan

nasnarnat

Explanation:

Following are the description of program

  • In the main function we read the three value by the user in the "s", "r" and "t" variable respectively.
  • After that call the function cat_rev() by pass the variable s,r and t variable in that function .
  • Control moves to the function definition of the cat_rev() function .In this function we reverse the string one by one and concat the string by using + operator .
  • Finally in the main function we print the reverse of the concat string   .

You might be interested in
The weight of your car will also affect its_____.
Usimov [2.4K]

Answer: C

Explanation:

4 0
2 years ago
Read 2 more answers
The following code does not work as intended. It is meant to input two test grades and return the average in decimal format:
vredina [299]

Answer:

Type casting error

Explanation:

Logically, the program is correct and it is expected to return the average value. However, test1 and test2 are int values and when you applies any algebraic expression on Int, it will result into Int.

So, in this part (test1 + test2 )/2, two integers are adding and the final result is still an integer and this part will act as an integer even if you multiple or divide with any external number.

For example,

test1 = 4

test2 = 5

test1 + test2 = 9

Now, if you divide it by 2, it will still react as an integer portion. So, 9/2 would result in 4 instead of 4.5. All the calculation is done on the right side before assigning it to a double variable. Therefore, the double variable is still getting the int value and your program is not working correctly.

The solution is to typecast the "(test1 + test2 )/2" portion to double using Double.valueOf(test1 + test2)/2 ;

I have also attached the working code below.

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

 System.out.println("Hello World");

 Scanner scan = new Scanner (System.in);

 int test1 = scan.nextInt();

       int test2 = scan.nextInt();

       double average = Double.valueOf(test1 + test2)/2 ;

       System.out.println("Answer: " + average);

}

}

4 0
3 years ago
A Google Doc automatically moves text to the next line when it reaches the right edge of the screen, is called:
DanielleElmas [232]
Word Wrap

As the name allows, the word wraps around the document once it reaches the border, thus making it the answer.

Hope this helps!
4 0
3 years ago
Read 2 more answers
These are code parts which can be collapsed or extended
skelet666 [1.2K]

Answer:

?????????? are there any options

3 0
2 years ago
This part of the electromagnetic spectrum can be used to generate power.
timurjin [86]
A. Gamma Rays is the answer. 
6 0
2 years ago
Read 2 more answers
Other questions:
  • Which tab is used to insert a hyperlink onto a slide
    8·2 answers
  • List at least 4 types of works covered by copyright law
    5·1 answer
  • Similarities between inline css and internal css​
    6·1 answer
  • Which of the following is not a benefit of shaping data with the Power Query Editor?
    13·1 answer
  • Write a method called removeHighPrice that will go through a provided ArrayList called prices and removes the first price that i
    6·1 answer
  • HELP PLEASE!!!! Which development method is best explained in this way: developing a system through repeated cycles and smaller
    10·1 answer
  • Explain basic anatomy of computers.
    13·2 answers
  • Help me<br>please answers this questions<br>​
    6·1 answer
  • Can anyone tell me about Microsoft some important features for partical
    11·1 answer
  • What Is The First Computer Brought In Nepal ? <br>​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!