answer.
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
A large industrial machine is able to monitor environmental conditions and quickly shut down and sound an alarm when it detects
Tamiku [17]

The feature of technology that allows this to happen is d. reduced latency.

Latency is the amount of time it takes for data to be transmitted in a network. Reduced latency therefore refers to a situation where data is transmitted with speed.

Reduced latency allows:

  • better communication
  • reduced lag and,
  • better gaming

The machine in question is only able to quickly sound the alarm because it has low latency.

In conclusion, we can say that low latency enables the machine above to sound the alarm quickly which means that low latency is important to the safety of that environment.

<em>Find out more at brainly.com/question/9337524.</em>

Options for this question include:

a. improved bandwidth

b. connection density

c. effective range

d. reduced latency

6 0
2 years ago
Read 2 more answers
A school principal trying to find out if parents will help buy new playground equipment shows digital leadership by.
ELEN [110]

Answer:

D. is the correct answer!

8 0
2 years ago
Read 2 more answers
Explain an application of a data communication system, including issues encountered with implementing the application.
aleksandrvk [35]

Answer:

Data communication system is referred to the exchange of information between the sender and receiver by use of transmission media.

Explanation:

The data communication system is referred to as the exchange of information between the sender and receiver by the use of transmission media.

some application of data communication system are;

videoconferencing,  

instant messaging

Telnet, etc.

In the data communication system, one information is transferred is transmission circuit then the media transfer the information to the receiver into the desired format.

the main issue is:

- data privacy

- cost of implementation

- use of the system for personal used during working hour

6 0
2 years ago
Complete the function ConvertToDecadesAndYears to convert totalYears to decades and years. Return decades and years using the Ti
Sergeeva-Olga [200]

Answer:

It is a C++ program. The complete function   ConvertToDecadesAndYears which takes totalYears as parameter and convert totalYears to decades and years is provided in the attached document.

Explanation:

The explanation is provided in the attached document.

The screenshot of the complete code along with its output is attached.

6 0
2 years ago
Which code fragment would correctly identify the number of arguments passed via the command line to a Java application, excludin
blondinia [14]

Answer:

The answer is a. int count =args.length

Explanation:

Which code fragment would correctly identify the number of arguments passed via the command line to a Java application, excluding the name of the class that is being invoked?

a. int count = args.length;

b. int count=0; while (!(args[count].equals(""))) count ++;

c. int count = args.length - 1;

d. int count = 0; while (args[count] != null) count ++;

The answer is a. int count =args.length

args is a string array object, which contains set of all arguments. You can find the number of argument by using args.length.

8 0
2 years ago
Other questions:
  • Which behavior could be acceptable at a classical concert as well as at a ball game? standing for an exceptional performance che
    9·2 answers
  • Which of the following are recommended techniques for protecting computer files and data? Check all of the boxes that apply.
    15·2 answers
  • Is used to process certificates and private/public key information?
    12·1 answer
  • Which of the following is not one of the four methods for classifying the various instances of malware by using the primary trai
    9·1 answer
  • As in algebra, you can use brackets to override the order of operations Excel follows to perform formula calculations. True or f
    13·1 answer
  • Which of the following option is correct about HCatalog?
    14·1 answer
  • Lynn runs the locate command and the results include many files from a directory that she doesn't want to include in her search.
    11·2 answers
  • Write a destructor for the CarCounter class that outputs the following. End with newline.
    9·1 answer
  • Choose the correct function to convert the user’s response to the number 3.5. &gt;&gt;&gt; answer = input("How much does the sam
    10·2 answers
  • Jason Chang is creating photos of his restaurant for a new website. Some of the photos of the staff have red eye, others are bad
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!