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
The Local Government Authority of Ghana wishes to computerize their activities. The Authority desires departments and units to b
Hatshy [7]

Answer:

wireless connection

Explanation:

key point worth noting : reduces some unnecessary cost

As the Head of IT unit your Head of Department, I will recommend that wireless connection should put in place. wireless connection will reduce cost of laying wires to different department of the Local Government Authority and also save record time that would have been used up during the installation.

Major benefits of wireless networking

1. Increased network coverage: wireless networks  can be used to reach  places in Local Government Authority office that are not accessible for wires and cables.

2. Improved Scalability: Wireless systems can be configured to meet the needs of specific departments of the Local Government Authority. These can be easily modified and scaled depending on each department’s needs.

3. Lower overall cost:Wireless Networking is relatively less costlier than wired Networks since no cables is required between the devices as well as lower long-term costs due to lesser maintenance fees since there is less equipment.

4 0
3 years ago
Pls help! 7th grade pythin fyi
larisa [96]

Answer:

There should be a colon at the end of the if statement, ie:

<h2>if x > 100:</h2><h2>  print("...")</h2>

8 0
3 years ago
In today's digital world, companies have created software that makes business communication and productivity more efficient and
Svetach [21]

Answer:

Business communications tools are widely used and the world is becoming increasingly digital so not having those skills will hinder you.

Explanation:

Many jobs require knowledge of Microsoft tools as a qualification. By not having that expertise, I will be viewed as less qualified for a position and may be passed up for job. In corporate America, presentations are a staple and Microsoft PowerPoint is the primary software. If I deliver a poor presentation due to inexperience, I will make myself look bad and as a result get a bad quarterly review and possibly stunted any future promotions. On the flipside, as a business owner Excel is a handy tool for tracking expenses. Very customizable, quick and easy to understand.

7 0
3 years ago
Is sonic better than piranha plant
nevsk [136]

Yes, well, in my opinion at least, Sonic will always be better than Piranha Plant.

7 0
4 years ago
Read 2 more answers
Write 'T' for true and 'F' for false statements.
asambeis [7]
1-F
2-T
3-F
4-F
5-F
6 T
7-T
3 0
3 years ago
Other questions:
  • Write the definition of a function named rcopy that reads all the strings remaining to be read in standard input and displays th
    6·1 answer
  • Which of the following is FALSE?
    8·1 answer
  • Write the definition of a function divide that takes four arguments and returns no value . The first two arguments are of type i
    8·1 answer
  • The computer that provides information or resources to the client computers on the network is called a(n) ________.
    5·1 answer
  • With landscape photography, which depth of field do you normally want? A) Small B)Small to Medium C)Large D)With landscapes it d
    7·2 answers
  • Why transport layer is usingconnectionless services if network layer is providing connection oriented services?
    10·1 answer
  • The Uniform Commercial Code (UCC) attempts to provide: a. a framework for international contracts. b. a body of rules for dealin
    15·1 answer
  • Karen works in a department store. Her coworker gave diverse cultural backgrounds. Which statement shows that Karen understand t
    14·1 answer
  • 5) Match the following.
    12·1 answer
  • In the earliest stages of human history, what was the only medium?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!