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
One of the most common uses of spreadsheet are
otez555 [7]

I think it is Index Match?

6 0
3 years ago
Please help!! I need this asap! thank you so much!! <3
ValentinkaMS [17]
I think it’s the last one
6 0
3 years ago
why do networking components need more examination from an information security perspective than from a systems development pers
padilas [110]
Networking components will eventually interact with computers and devices outside of itself. Whereas during system development you are only interacting with your program internally.

For example, when you first work on a website you can begin working on it on your personal computer not connected to the outside world. When you are done working on your website you will now upload it to a webserver (or you will create your webserver) and now you are opening up the doors so to speak to the Internet. When you "open the door" you need to make sure the proper security is in place so that no one hacks your site. This is ussually done by making sure the webserver you are on does not have any known security vulnerbilities and has the proper firewall settings to prevent unauthorized access.
4 0
3 years ago
You view a portion of a document on the screen through a ____.
alekssr [168]

You view a portion of a document on the screen through a C. Document window

- Mabel <3

8 0
3 years ago
Write a program that takes in an integer in the range 20-98 as input. The output is a countdown starting from the integer, and s
S_A_V [24]

Answer:

// program in C++.

#include <bits/stdc++.h>

using namespace std;

int main() {

//  variable  

int num;

cout<<"Enter the number between 20 and 98: ";

// read number

cin >> num;

while(num<20||num>98)

{

   cout<<"Wrong input!!enter number between 20-98 only:";

   cin>>num;

}

cout<<"The output is: ";

while(num % 10 != num /10)

{

// print numbers.  

cout<<num<<" ";

// update num.

num--;

}

// display the number.

cout<<num<<endl;;

return 0;

}

Explanation:

Read a number from user and assign it to variable "num".Check if entered number  is in between 20-98 or not.If input number is less than 20 or greater than 98 then  ask again to enter a number between 20-98 until user enter a valid input.Then print  the countdown from input number till both the digit of number are same.

Output:

Enter the number between 20 and 98: 99                                                                                    

Wrong input!!enter number between 20-98 only:12                                                                            

Wrong input!!enter number between 20-98 only:93                                                                            

The output is: 93 92 91 90 89 88

Enter the number between 20 and 98: 77                                                                                    

The output is: 77

7 0
3 years ago
Other questions:
  • Write a C++ program that searches for anagrams in a dictionary. An anagram is a word obtained by scrambling the letters of some
    5·1 answer
  • What is a bus master?
    14·1 answer
  • ​open-source software is​ ________.
    11·1 answer
  • Computer design replaced ______________
    6·1 answer
  • User can use ______ commands to search for and correct words in a document
    13·1 answer
  • Does the estimate of a tolerance level of 68.26% of all patient waiting times provide evidence that at least two-thirds of all p
    13·1 answer
  • You can find synonyms and disciplinary jargon in the ______, _______, and ______ in your search results. You can then use these
    13·1 answer
  • Excel files have a default extension of ?
    12·1 answer
  • Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input
    5·1 answer
  • when demonstrating 2022 altima’s parking assistance, what steering feature should you mention when pointing out how easy the veh
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!