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
A _______ is the most commonly used input device.
nirvana33 [79]
The answer is B.Keyboard
4 0
3 years ago
Read 2 more answers
Some people argue that developers should not be involved in testing their own code but all testing should be the responsibility
GalinKa [24]

Answer:

People code in their own styles which can make it hard for other people to understand it, especially if it doesn't have any documentation, but that could be a reason to let a separate team test it, so the developer can learn how to code in a way that is understood by most people.

Explanation:

7 0
3 years ago
Which is an example of a withholding you might see on your pay stub?
Arisa [49]
An example of a withholding you might see on your stub who'll be money.
3 0
3 years ago
Write a java program that asks the student for his name and Favorite basketball team. The program should then welcome the studen
bixtya [17]

The java program is an illustration of sequential programs

<h3>What are sequential programs?</h3>

Sequential programs are programs that do not require loops or conditions

<h3>The actual program</h3>

The program written in Java, where comments are used to explain each line is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

 //This creates a Scanner Object

 Scanner input = new Scanner(System.in);

 //This declares the variables

 String name, team;

 //This prompts the user for name

 System.out.print("Name: ");

 //This gets an input from the user

 name = input.nextLine();

 //This prompts the user for favorite team

 System.out.print("Favorite team: ");

 //This gets an input from the user

 team = input.nextLine();

 //This prints the required output

 System.out.print("Welcome, "+name+". Cheers to "+team+" team");

}

}

Read more about sequential programs at:

brainly.com/question/26642771

7 0
3 years ago
Read 2 more answers
The _____ component of a database management system (dbms) is used to add, delete, modify, and retrieve records from a database.
ikadub [295]
The correct answer is:  [A]:  "data manipulation" .
________________________________________________________
3 0
4 years ago
Read 2 more answers
Other questions:
  • What is a computer network that provides connectivity in a geographic area or region larger than that covered by a local area ne
    7·1 answer
  • What does it mean when your phone says system ui has stopped?
    7·1 answer
  • Send the memes whoever is the best will get that crown thing lol
    10·2 answers
  • Does anyone know what the name of the game is, where you click on the grey dots in a 3x3 grid and try to make them all the same
    10·1 answer
  • What are QBASIC Operators ?​
    11·2 answers
  • Whe you read anything online how do you know whether or not is coming from a reliable source?
    14·2 answers
  • Complete the sentence.
    9·1 answer
  • For each problem listed below, use the drop-down menu to select the field of the professional who can help solve the issue.
    7·2 answers
  • HELPPPPP!!! Performance Check: Mini-Quiz
    15·1 answer
  • ___ data is ____data; non-numeric data; observations are organized into categories without any recognition of order.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!