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
torisob [31]
3 years ago
6

Ask the user to enter the number of elements in a list of numbers. Take in the numbers from the user and then output the list th

e user entered . Followed by the list the user entered with only the 2nd half sorted. NOTE: You may assume the user will enter a list with an even number of elements. You should sort only the 2nd half the first half is to remain as is.

Computers and Technology
1 answer:
m_a_m_a [10]3 years ago
4 0

Answer:

#Section 1

   lst= []

   lstNo=int(input("Enter even number of elements in List: "))

   for i in range(0, lstNo):

       pr=int(input(": " ))

       lst.append(pr)

   print(lst)

#Section 2

   nlst=[]

   dlst=[]

   n =len(lst)

   i=0

   while (i < n/2):

       nlst.append(lst[i])

       i = i+1

   j = n-1

   while j >= n/2:

       dlst.append(lst[j])

       j = j-1

   dlst.sort()

   for a in range(len(dlst)):

       nlst.append(dlst[a])

   print(nlst)

       

Explanation:

#section 1:

An empty list is declared to hold the list inputs by the user <em>lst= [] </em>

The program then prompts the user to enter an even number of elements that will be contained in the list.

The for loop is used to iterate from zero(0) to the number of elements stated, in order to get the input that is appended to the list.

lastly, the list is printed out.

#Section 2:

In this section two new lists are created to hold one half of the value respectively.

The first list collects the first half of the list using a while loop and stores it, it does not perform any sorting on it.

The second list collects the second half using a while loop and sorts the list using the<em> .sort()  </em>method which arranges elements in an ascending order.

Finally, the second list that has been sorted is added to the first and the result is printed to the screen.

A picture of how the code will run has been attached.

 

You might be interested in
A _______________ is a particular type of network that uses circuits that run over the Internet but that appears to the user to
ArbitrLikvidat [17]

Answer:

A virtual privte network is a particular type of network that uses circuits that run over the Internet but that appears to the user to be a private network.

5 0
2 years ago
Which of the following statements regarding EFT is false? EFT still requires the endorsement of a check EFT allows payment to be
hammer [34]

A smart way of moving money from one personal banking account directly to another account is called EFT or electric fund transfer. There is a maximum clearance time of 24 hours for transfer.  The most widely-used program is Direct Deposit, in which payroll is deposited straight into an employee's bank account initiated through an electronic terminal, including credit card, Therefore, the following<span> statement regarding EFT is false?</span>

<span>1.                  </span><span>EFT still requires the endorsement of a check </span>

3 0
3 years ago
Read the following scenario: A project will require more people than originally estimated. Identify the possible risks to the pr
egoroff_w [7]
A ideas and creativity
8 0
3 years ago
Read 2 more answers
What tool is used to find and organize files on a mac
Margaret [11]

Answer:

the tool is literally called <u><em>The Finder.</em></u>

Explanation:

hope this helps

4 0
2 years ago
JavaScript is the same thing as Java?
Mila [183]

Not really, because Java is an OOP programming language and JavaScript is an OOP scripting language.

Hope I helped!

~Mshcmindy

5 0
2 years ago
Read 2 more answers
Other questions:
  • If you print a document with red green or blue underlines will they show up on printed pages
    14·1 answer
  • One lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input
    12·2 answers
  • Write a program that inputs a time from the console. The time should be in the format "HH:MM AM" or "HH:MM PM". Hours may be one
    6·1 answer
  • Describe how a cell’s content and format attributes are related.
    13·2 answers
  • Use the drop-down menus to complete the statements about changing mail options in Outlook.
    10·1 answer
  • Micro sleep is when you ____.
    11·2 answers
  • Drag the tiles to the correct boxes to complete the pairs.
    13·1 answer
  • Random.choice will choose a number between 1 and 100. True False​
    6·1 answer
  • What is the difference between algorithm and program?
    10·1 answer
  • Your development team is planning to host a development environment on the cloud. This consists of EC2 and RDS instances. This e
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!