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
jeyben [28]
3 years ago
14

Task1: #Define a function called show_students which takes 2 parameters students and message #Print out a message, and then the

list of students #Next, put the students in alphabetical order and print them #Next, Put students in reverse alphabetical order and print them Example Output: Our students are currently in alphabetical order. - Aaron - Bernice - Cody Our students are now in reverse alphabetical order. - Cody - Bernice - Aaron
Computers and Technology
1 answer:
k0ka [10]3 years ago
6 0

Answer:

  1. def show_students(message, sList):
  2.    print(message)
  3.    print(sList)
  4.    print("Our students are currently in alphabetical order")
  5.    sList.sort()
  6.    output = ""
  7.    for student in sList:
  8.        output += "-" + student
  9.    print(output)
  10.    print("Our students are currently in reverse alphabetical order")
  11.    sList.sort(reverse=True)
  12.    output = ""
  13.    for student in sList:
  14.        output += "-" + student
  15.    print(output)  
  16. show_students("Welcome to new semester!", ["Aaron","Bernice", "Cody"])

Explanation:

Firstly we declare a function that will take two inputs, message and student list (Line 1).

In the function, we first print the message and the original input student list (Line 2 - 3). Next, we use sort method to sort the input list and then output the sorted items from the list using a for loop (Line 5-10).

Next, we sort the list again by setting reverse = True and this will sort the list in descending order (Line 13). Again we use the similar way mentioned above to output the sorted items (in descending order) using a for loop (Line 14 -17)

We test the function using a sample student list (Line 18) and we shall get the output:

Welcome to new semester!

['Aaron', 'Bernice', 'Cody']

Our students are currently in alphabetical order

-Aaron-Bernice-Cody

Our students are currently in reverse alphabetical order

-Cody-Bernice-Aaron

You might be interested in
Why procedures are used and what must be the lastexecutable instruction in a<br><br> procedure?
Art [367]

Answer:

Procedure are used to create and modifying the programs. Basically, it is grouping of instruction that can be used give direction of the flow of program. Control are given to the next term once the execution of the instruction get over. The steps of procedure are:

procedure are first executed the declaration instruction and then coding the procedure, then it will return to the directories and the last executable instruction is the termination of procedure.

4 0
3 years ago
In what way can a costume be deleted ?
alex41 [277]

Answer:

Clicking the "X" button towards the upper-right of each costume's icon in the Costume Pane will delete

Explanation:

5 0
3 years ago
What is the distinction between a network and an internet?
kompoz [17]
Hi,

Network: Is group of computers connected together via communications devices and transmission media.

Internet: Is a worldwide collection of networks that connect Governments, Businesses, Institutions and Individuals thought their personal devices.

Hope this helps.

r3t40
8 0
4 years ago
2. Feet to Inches One foot equals 12 inches. Design a function named feetToInches that accepts a number of feet as an argument,
MariettaO [177]

Answer:

See the below the answer written in Matlab

Explanation:

function inches=feetToInches(feet)

prompt='enter the value of feet in digits';

feet=input(prompt)% ask for the value in feet that needs to be converted to inches

inches =feet*12; % converts feet to inches

x=['the value in inches is:  ',num2str(inches)];

disp(x) %display the result of the convertion

end

8 0
3 years ago
What is the lower House​
statuscvo [17]
What lower house need context
6 0
4 years ago
Other questions:
  • What type of computer would integrate the system unit with the display and keyboard?
    7·1 answer
  • This is going to get taken down but I dont care add me on discord cause ima bored<br> -Red-#9847
    12·1 answer
  • A low concentration of market power has positive affects. A low concentration of market share has which of the following effects
    7·1 answer
  • When typing the Works Cited in a report, set a .5" ______ indent. *
    12·1 answer
  • What were the technological innovations that allowed for the rapid expansion of the railroads?
    6·1 answer
  • Whats wrong with my code for .addEventListener
    11·1 answer
  • Read two numbers from user input. Then, print the sum of those numbers. Hint - Copy/paste the following code, then just type cod
    9·1 answer
  • (b) In Scratch, the instruction 'when I receive' enables us to _____ the action of multiple sprites ​
    5·1 answer
  • (iii) ............ characters can be stored in memo field. (a) 50 (b) 64000 (c) 255 (d) 200 ​
    8·1 answer
  • Record the issue of 4,000 shares of $5 par value common stock for $35000 cash
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!