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
24 bit or 16 million colors is often called?
galben [10]
Is it bit-depth maybe????
7 0
3 years ago
How should font appear in a slide presentation compared to the font in a document
saul85 [17]

Answer:

larger in a presentation, smaller on a document.

Explanation:

this makes it easier to tell which is which.

3 0
3 years ago
.In Python, comments begin with the comment marker and continue ______.
earnstyle [38]

Answer:

b. to the end of the line

Explanation:

Great question, it is always good to ask away and get rid of any doubts that you may be having.

Python is a unique language compared to other languages such as Java and C++. In Python comments are started with the comment marker which is the hashtag (#) symbol and continues <u>to the end of the current line</u>. Once the line ends the next line is <u>NOT</u> automatically considered a comment unless another hashtag is placed.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

4 0
2 years ago
List four reasons of meaningful use that demonstrate the capabilities and processes required for the provider to show active use
Naily [24]

<span>1.       </span>Improve quality of care and reduce health disparities.

<span>2.       </span>Read the orders in the medical record and make sure to read it back again to verify accuracy.

<span>3.       </span>Maintain the security and privacy of patient health information.

<span>4.       </span>Talk to the patients and families in management of their health care.






7 0
3 years ago
What enables image processing, speech recognition, and complex game play in Artificial Intelligence (AI)?
zysi [14]

Explanation:

Deep Learning enables image processing, speech recognition, and complex game play in Artificial Intelligence

3 0
3 years ago
Other questions:
  • Reggie has hired you to design a home network. The home network will share a printer but will mainly be used to stream movies to
    7·1 answer
  • which telecommunications service allows internet and telephone service to work over the same phone line
    13·1 answer
  • The moon has less mass than the earth, so what happens to objects on the moon?
    11·1 answer
  • Which of these is an example of rebranding ?
    6·2 answers
  • How does it transform your ways of socializing
    11·1 answer
  • In _____, a program running on a Web server creates a Web page in response to a request for specific information from a Web clie
    7·1 answer
  • Which of the following is a key difference between a Windows 7 restore point and one you set yourself?
    11·1 answer
  • Actividades que puedes Aser con un martillo y su explicación
    8·1 answer
  • The owner creator of a folder/file object has complete access to the object even when no user or group is assigned any access to
    8·1 answer
  • question 2 which data link layer protocol defines the process by which lan devices interface with upper network layer protocols?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!