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]
2 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]2 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
Which word is most appropriate to describe a laptop?
Thepotemich [5.8K]
The best word to describe a laptop would be Portable
8 0
2 years ago
What does expected initializer before ". " token mean?
densk [106]

;l p lm k                  nnnnnnnnnnnnnnnnnnnnnnnnnnnnnn

4 0
2 years ago
Help , i couldn’t find this answer
Aleksandr-060686 [28]

Answer:

Internet Explorer

Explanation:

4 0
3 years ago
What’s my password for this app
FrozenT [24]

Answer:

I guess there isnt any password!

Explanation:

7 0
3 years ago
Read 2 more answers
A large gambling company needs to be able to accept high volumes of customer wagers within short timeframes for high-profile spo
Dima020 [189]

Answer: A. a mobile app that only accepts wagers based on the user's location

Explanation:

Elastic cloud simply refers to the cloud computing offering which due to the need for change helps in the provision of variable service levels.

Based on the information given in the question, an effective elastic Cloud solution that can meet this client’s needs is a mobile app that only accepts wagers based on the user's location.

Since there are strict laws that prohibit gambling activities outside the licensed zones, the user location is vital in the mobile app.

5 0
2 years ago
Other questions:
  • ACCOUNTING
    13·2 answers
  • When a browser makes a request for a static web page, the web server a. finds the HTML for the page and renders it b. renders th
    11·1 answer
  • Information from the system that is used to make modifications in the input, processing actions, or outputs is referred to as: G
    9·2 answers
  • Then standard toolbar appears whenever you select text true or fals
    15·1 answer
  • Wide area network (WAN) connects multiple networks that are in the same geographical locations.
    6·1 answer
  • Murray is a database technician. He has created a single enterprise database system. How is this better than multiple databases
    15·1 answer
  • To join a social network you create an avatar true or false
    6·2 answers
  • Tennis players are not allowed to swear when they are playing in Wimbledon
    6·2 answers
  • Who benefits from digital technology?
    15·1 answer
  • Who invented computer ?​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!