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
prisoha [69]
3 years ago
10

Write a function swap that swaps the first and last elements of a list argument. Sample output with input: 'all,good,things,must

,end,here' ['here', 'good', 'things', 'must', 'end', 'all']
Computers and Technology
2 answers:
asambeis [7]3 years ago
8 0

Answer:

def swap(li):

   n=len(li)

   li[0],li[n-1]=li[n-1],li[0]

   return li

Explanation:

Python is very user friendly language and and this provides numerous functions and in-built services. In the above function, i have created a method which is taking an argument li and we can find the length of li by using method len() which is then stored in variable n. Now we have to swap first and last element so, first element of li is li[0] and last is li[n-1]. Python provides one more utility in which we can change values of 2 elements simultaneously by separating them with comma. So, we put the value of last element in first and value of first in last which saved many lines of code.

zubka84 [21]3 years ago
7 0

Answer:

li=list(map(str,input().strip().split()))#taking input of the string.

#swapping first and last element.

temp=li[0]

li[0]=li[-1]

li[-1]=temp

print(li)#printing the list.

Explanation:

I have taken the list li for taking the input of strings.Then after that swapping first and last element of the list.Then printing the list.

You might be interested in
Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in
Sladkaya [172]

Answer:

The program written in Java is given in the explanation section

Explanation:

public class num9 {

//Defining the method CountCharacters()

   public static int CountCharacters(char userChar, String userString){

       int c = userString.length();

       int count=0;

       for(int i=0; i<c; i++){

           if(userString.charAt(i)==userChar){

               count++;

           }

       }

       return count;

   }

//Main method begins here

   public static void main(String[] args) {

   char n ='n';

   String word = "Monday";

//Calling the method CountCharacters()

       System.out.println(CountCharacters(n,word));

   }

}

4 0
3 years ago
in a client server architecture what are the three propoerties of a client and three properties of a server
polet [3.4K]

The three properties of a client and three properties of a server are mentioned to take the initiative in communication, etc.

<h3>What is server architecture?</h3>

Server architecture is the basic design or blueprint from which a server is built and/or deployed.

Client: takes the initiative in communication, doesn't speak to other clients directly, and only has to be online while a procedure is being completed.

The server is always running, waits for communication to begin, and serves several clients at once.

Thus, the three properties of a client and three properties of a server are mentioned to take the initiative in communication, etc.

Learn more about the server architecture here:

brainly.com/question/15220127

#SPJ4

4 0
2 years ago
What should you do before cleaning the top of a storage battery and rinsing it with fresh water?
Montano1993 [528]
D. Discharge the battery completely
6 0
3 years ago
The stack ADT may be implemented with
Masteriza [31]

Answer: (c)All others answers

Explanation: Stack ADT is the group of the objects that are present  to work according to the last in first out strategy for the abstract data types. It works on the insertions and deletion of the elements that is referred as the push and pop action.

The ADT stacks can works with arrays, links list as well as vectors for the operation .Therefore, the correct option is option(c)

4 0
3 years ago
5. In Access, data is stored in a _______ once a form is completed. A. cell B. page C. record D. form
guajiro [1.7K]
Cell dosent make sense at all, page also is completely nonsense, fourm also has nothing to do with stored data. Your awnser is C. Record 
3 0
4 years ago
Other questions:
  • Which resource do programmers sometimes have to refer to and use during planning the logical steps of the solution?
    10·2 answers
  • Select the instances in which you should include a comma.
    14·1 answer
  • Can folders have mixed apps?
    6·1 answer
  • Which module is missing from most expert systems? a. Knowledge base subsystem b. Inference engine c. User interface subsystem d.
    5·1 answer
  • Which type of project data would you review for an accurate picture of the project progress and labor costs
    8·1 answer
  • What programming language does the LMC 'understand'?
    5·1 answer
  • A large number of consecutive IP addresses are available starting at 198.16.0.0. Suppose that four organizations, Able, Baker, C
    11·1 answer
  • Heya! I’m quite lonely, so here are some points. I want to play some mc with others but the only version I’m able to play is edu
    11·2 answers
  • PLZ PLZ PLZ PLZ HELP I ONLY HAVE 5 MINUTES IT SAYS THE SUBJECT IS COMPUTERS AND TECHNOLOGY BUT ITS ACTUALLY MEDIA LIT
    5·1 answer
  • List four tasks that humans perform frequently, but which may be difficult for a computerized agent to accomplish. Describe the
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!