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]
2 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]2 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]2 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
How long does it take 2 consultants to create a slide deck of 120 slides, assuming one consultant make 2 slides per hour?
Andreyy89

It would take 2 consultants 30 hours to create a slide deck of 120 slides.

Explanation:

Rate of slide making by one consultant- 2 slides per hour

Target- 120 slides

2 consultants are employed in the job-  

Since 2 consultants are employed in the job, total rate of making slides per hour would be 4 slides/hour (2*2 slides/hour)

Time required to complete 120 slides= total slides/rate of doing slides per hour

Substituting the values, we get

Time required= 120/4= 30 hours

Hence, it would take 30 hours for 2 consultants to create a slide deck of 120 slides.

7 0
3 years ago
(tco 6) after connecting to an ftp site, the _____ command will upload multiple files.
m_a_m_a [10]
<span>After connecting to an ftp site, the mget command will upload multiple files.
</span><span>The </span>mget command<span>  retrieves multiple files from a remote server directory and stores them in the current local directory.
</span><span>ftp> mget <start of the like files> *
</span>

ftp> mget file01 file02 file03

ftp> mget filename*

ftp> mget *.txt

5 0
3 years ago
Which of these monitor connector types is the oldest and least desirable to use?
ella [17]

Answer:

DVI is the oldest out of the four.

Explanation:

DVI and VGA are the oldest, but DVI is oldest and least desirable to use since it is outdated.

5 0
3 years ago
Read 2 more answers
A relational database is different from a simple database because it has more than one _____. record ID number table field
Ulleksa [173]

Answer:Table

Explanation:A relational database has structures and thus have more than one table. The tables consist of row (for entry) and column (for data). As a result, data are organized in a simple manner and are normally consistent.

6 0
3 years ago
A corporate user is attempting to connect to the company’s Windows domain server on the local network with her new laptop throug
andreev551 [17]

Answer:

B. Windows domain user name and password

Explanation:

Windows domain user name and password are login credentials required for the user to successfully sign in to the Windows domain.

The domain username and password are usually stored on a domain controller rather than on the host.

As a domain user, the computer seeks from the domain controller the privileges assigned to the user, if it gets a positive response from the domain controller, it authorizes the users login credentials without restrictions; else, it denies the user access.

8 0
3 years ago
Other questions:
  • Where can you change your web page SafeSearch settings?
    8·1 answer
  • Integrated circuits are made up of _____ and carry an electrical current
    14·1 answer
  • True or false
    7·1 answer
  • Identify the following as True or False.
    14·1 answer
  • Match each type of software license with the appropriate definition.
    11·1 answer
  • Suppose a process in Host C has a UDP socket with port number 6789. Suppose both Host A and Host B each send a UDP segment to Ho
    8·1 answer
  • Many companies use telephone numbers like 555-GET-Food so the number is easier for their customers to remember. On a standard te
    6·2 answers
  • A customer uses an app to order pizza for delivery. Which component includes aspects of the customer's interaction with an enter
    10·1 answer
  • Guess The Song:
    9·1 answer
  • King(a. has eaten b.ate c.had eaten) when Airah called​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!