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
You are working on a project and need to be able to access the content from home and share the files with other team members. Th
inn [45]
Local server so you can all you use if you guys are near
5 0
3 years ago
Read 2 more answers
Write an ALTER TABLE statement that adds two new columns to the Products table: one column for product price that provides for t
matrenka [14]

Answer:

ALTER TABLE Products

ADD Products_price float(5,2) DEFAULT 9.99,

ADD Adding_time datetime;

Explanation:

So at first we need to use ALTER TABLE statement, when we use this statement we also need to provide the table name. In this case, i assume it is 'Products'.

Then, as per question, we need to add two columns.

The first one is 'product_price' and it contains decimal points. So, we need to use ADD statement and give a column name like 'Prodcuts_price' and its datatype 'float' because it contains decimal or floating points. so, for 3 digits on the left and 2 digits on the right, it makes a total of 5 digits. So, we need to declare it like this. (5,2) it means a total of 5 digits and 2 after the decimal point. after that, we need to set our Default value using the DEFALUT statement. so DEFAULT 9.99. it will set the default value to 9.99 for existing products.

And for our next column, we give its a name like 'Adding_time' then it's datatype 'datetime' because it will contain date and times.

8 0
3 years ago
hackers can use as part of a reconnaissance process to learn about active network addresses and active processes?
aalyn [17]

Answer:

ICMP.

Explanation:

Hackers might use ICMP for gain knowledge about current system addresses and specific procedures as part of a reconnaissance process.

ICMP is a failure informing system used by network protocols such as routers to produce warning to that of the source Address while network issues interrupt IP packet transmission.

3 0
3 years ago
I need help please?!!!!
mrs_skeptik [129]
It would be wear a seatbelt
6 0
3 years ago
Read 2 more answers
A service provider recently upgraded one of the storage clusters that houses non-confidential data for clients. The storage prov
VARVARA [1.3K]

Answer:

<em>C. Purging</em>

<em></em>

Explanation:

<em>Data Purging in computer storage is a process that permanently erases and remove data from a storage space</em>.  Data deleting only removes the shortcut to the data but does not remove the data permanently, and can be easily recovered by an expert. <em>Data purging removes data permanently and also frees up the storage or memory space for other uses.</em> Data purging is relatively inexpensive and can be achieved with some special software tool.

Since the storage provider wants the hard drive back in working condition, data purging is the best option.

3 0
3 years ago
Other questions:
  • You want to register the domain name ABCcompany.org, but the registration service is not allowing you to do that. What's the mos
    10·1 answer
  • What is computing networking​
    5·1 answer
  • Your health insurance company gives you a discount if you wear a fitness-tracking bracelet. After wearing it for a few months, y
    5·1 answer
  • "what are the problems with tcp over wireless network?"
    15·1 answer
  • What are the factors affecting the purchasing decision for dbms software?
    7·2 answers
  • A speaker takes a variety of information from the results of a web search, and puts it together in an outline to make up his spe
    8·1 answer
  • Part of preforming routine computer maintenance includes
    9·2 answers
  • Justine was interested in learning how to play the piano. Before she was allowed to even play the piano, she has had to learn
    15·2 answers
  • Patronage of most Medieval musicians was supplied by the
    13·1 answer
  • What are the three main sub-sectors in the IT-BPM industry?<br>IT class 9​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!