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
BlackZzzverrR [31]
3 years ago
13

write a python function that takes the largest and smallest numbers in a list, and swap them (without using min() or max() )

Computers and Technology
1 answer:
Akimi4 [234]3 years ago
8 0

Answer:

def SwapMinMax ( myList ):

   myList.sort()

   myList[0], myList[len(myList)-1] = myList[len(myList)-1], myList[0]

   return myList

   

Explanation:

By sorting the list, you ensure the smallest element will be in the initial position in the list and the largest element will be in the final position of the list.

Using the len method on the list, we can get the length of the list, and we need to subtract 1 to get the maximum element index of the list.  Then we simply swap index 0 and the maximum index of the list.

Finally, we return the new sorted list that has swapped the positions of the lowest and highest element values.

Cheers.

You might be interested in
ven int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 5
monitta

Answer:

Following are statement is given below

int  k=1,total=0; // variable declaration

while(k<50) // iterating the while loop

{

   total=total+k*k;//  calculating the square

   k=k+1; // increments the value of k by 1    

}

Explanation:

Following are the description of Statement.

  • Declared a variable "total" and "k" of the "integer " type initialized the total to 0 and "k" to 1.
  • Iterating the while loop for less then 50 .In this loop, we calculating the sum of square of first 50 number in the "total" variable .
  • After that increment the value of "k" variable by 1 to execute the loop less then 50 .

3 0
3 years ago
When a web page author includes meta keywords, like sex, that have little to do with the information on the page, the author is
OLga [1]
This practice is known as "ClickBait".
8 0
3 years ago
Select the correct answer.
Marina86 [1]
C: pie chart is the answer to it
4 0
3 years ago
Read 2 more answers
Richard owns a chain of hardware stores. He wants to update the store website and write a numbered list of all the items in his
Digiron [165]
Use ordered list
  1. tag and put each item inside of a list item
  2. tag.
8 0
3 years ago
Read 2 more answers
Full Form of CPU AND RAM ?
sweet [91]

Answer:

IN COMPUTER TERMS:

CPU is centrsl processing unit

RAM is random access memory

7 0
3 years ago
Read 2 more answers
Other questions:
  • 1.<br> Which of the following is NOT caused by alcohol?
    15·2 answers
  • 5. Which of the following could occur making it necessary for Amy to troubleshoot her computer? Error messages keep popping up,
    12·1 answer
  • How to write a self-analysis essay
    5·1 answer
  • Audra recently earned her associate’s degree and is looking for a job. Her resume lists her strengths in a separate section. Som
    13·2 answers
  • The darker shadow of an eclipse is called the penumbra.<br><br> True<br><br> False
    12·1 answer
  • Write syntactically correct Javascript code to sort an array of sub-arrays containing integers using the sort and reduce array f
    11·1 answer
  • It is 10PM and you are inside in the middle of a large building. Your cell phone is dead so you cannot use wifi or cell signals
    7·1 answer
  • High level languages are closer to machine language than humans yes or no​
    12·2 answers
  • Why green office became popular among businesses? ​
    10·2 answers
  • EXPLAIN WHY CRYPTOCURRENCIES ARE NOT RELIABLE.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!