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
Why do we need to connect computers"​
Gennadij [26K]

Answer:

batteries cant last connected to nothing forever probably

8 0
2 years ago
_________function tells the cin object to skip one or more characters in the keyboard buffer.
Amanda [17]

Answer:

cin.ignore function written as  cin.ignore()

Explanation:

  • As we know that cin is an object that is used to obtain the input entered by the user through the keyboard.
  • cin.ignore() is a function which is used to ignore or skip one or more characters in the keyboard buffer.
  • Keyboard buffer is a small storage area which is used to store keystrokes.
  • When a key is pressed on the keyboard it is referred to as a keystroke.
  • So before processing, these keystrokes are stored in keyboard buffer.
  • So when we use cin to input a character from the user through the keyboard, the keyboard buffer must be empty. If that's not done then the character entered will be taken by the buffer of previous variable.
  • Lets take an example of why we want to use cin.ignore() function.
  • For example you want the employee (user) to enter his name and you are using cin to read this name from the user.

                                          char empname[8];

                                           cin>>empname;

  • Now if the user types his name lets say Anonymous and press enter key this will be taken as new line character and it will store this newline character \n into the buffer.
  • cin >> statement reads data from the buffer and stops reading when it reaches newline character.
  • So Anonymous is read in and stored in empname variable but newline character is left in the keyboard buffer.                          
  • Lets say after cin>>empname we write another statement that takes a character from user. A user wants to enter character "a".

                                char character;

                            character = cin.get();

  • When cin.get finds the newline  character \n in keyboard buffer, it uses it (as cin.get can read the newline character in the buffer) without waiting for the  user to input "a".
  • So cin.ignore() function is used to avoid such situation.
  • We can specify the characters to be ignore within the cin.ignore() function such as cin.ignore(10,'\n') will ignore 10 characters in the buffer before taking new line or until a \n character comes.
  • You can simply use cin.ignore() which will ignore the very next character just as \n in our example. In our example we can use cin.ignore() after the cin>>empname; and before using cin.get();
8 0
4 years ago
Splunk knows where to break the event, where the time stamp is located and how to automatically create field value pairs using t
schepotkina [342]

Answer:

The answer is "Option a".

Explanation:

Splunk is a software that is used for captures, indexes, and it provides a collection of real-time data. It is also known as a searchable archive that can be used to produce maps, charts, warnings, dashboards, and visualizations. It is a hierarchical system used to handle software, protection, and security, and to analyze enterprise and network. and other options are incorrect that can be described as follows:

  • In option b, It tells the name of the file and it also described the type of file like text file, image file, etc. That's why it is not correct.
  • In option c, This option is used to add data into the new line, that's why it is not correct.

7 0
4 years ago
Create a set of use cases for the following health club membership system:
Sveta_85 [38]

Answer:

The use case diagram is attached.

Explanation:

Create a set of use cases for the following health club membership system:

When members join the health club, they pay a fee for a certain length of time. Most memberships are for one year, but memberships as short as two months are available. Throughout the year, the health club offers a variety of discounts on its regular membership prices (e.g., two memberships for the price of one for Valentine's Day). It is common for members to pay different amounts for the same length of membership. The club wants to mail out reminder letters to members asking them to renew their memberships one month before their memberships expire. Some members have become angry when asked to renew at a much higher rate than their original membership contract, so that the clubwants to track the price paid so that the manager can override the regular prices with special prices when members are asked to renew. The system must track these new prices so that renewals can be processed accurately. One of the problems in the healthclub industry is the high turnover rate of members. While some members remain active for many years, about half of the members do not renew their memberships. This is a major problem because the health club spends a lot in advertising to attract each new member. The manager wants the system to track each time a member comes into the club. The system will then identify the heavy users and generate a report so that the manager can ask them to renew their memberships early, perhaps offering them a reduced rate for early renewal. Likewise, the system should identify members who have not visited the club in more than a month so that the manager can call them and attempt to reinterest them in the club.

The use case diagram is attached.

3 0
3 years ago
The Hootsuite Analytics overview automatically analyzes two time periods: the one you select, and the corresponding length of ti
Valentin [98]

Answer

The benefit is that it put your result in a more historical perspective

Explanation

The Hootsuite Analytics and measuring tools work to provide a complete report of the companies social media contributions at each marketing stages. The Hootsuite Analytics measures the overall performance , the effect for in depth analysis of shared posts including social listening. The analysis is able to monitor multiple social streams, schedule posts in advance  and create a simple analytics data for view


6 0
4 years ago
Read 2 more answers
Other questions:
  • If Maya wants to access a view that would control multiple slides within a presentation, which view should she utilize? Master v
    9·1 answer
  • Explain free space allocation?
    9·1 answer
  • Which of these jobs would be most appropriate for someone who majors in computer engineering? I need the answer ASAP Helping com
    14·2 answers
  • The negotiation by the transport layer at the sender with the transport layer at the receiver to determine what size packets sho
    14·1 answer
  • Write a JAVA program that repeatedly prompts your user for a number, uses a recursive function to calculate the product of that
    8·1 answer
  • By observing human behavior,_______are able to understand the cause and effect relationship between the supply of things we want
    13·2 answers
  • If you want to adjust the width of a column manually, move your mouse over the _______ column boundary and click and drag until
    9·1 answer
  • Which disc store compacity for full lenght movie? dvd or cd
    14·1 answer
  • Suppose L is a LIST and p, q, and r are positions. As a function of n, the length of list L, determine how many times the functi
    8·1 answer
  • Which work habits should you follow to increase work efficiency and avoid health issues?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!