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
netineya [11]
3 years ago
12

Given a sorted list of integers, output the middle integer. A negative number indicates the end of the input (the negative numbe

r is not a part of the sorted list). Assume the number of integers is always odd. Ex: If the input is:
Computers and Technology
1 answer:
masya89 [10]3 years ago
8 0

Answer:

The program in Python is as follows:

myList = []

num = int(input())

count = 0

while num>=0:

   myList.append(num)

   count+=1

   num = int(input())

myList.sort()

mid = int((count-1)/2)

print(myList[mid])

Explanation:

This initializes the list

myList = []

This gets the first input

num = int(input())

This initializes count to 0

count = 0

The following is repeated until the user inputs a negative number

while num>=0:

This appends the input number to the list

   myList.append(num)

This increments count by 1

   count+=1

This gets another input

   num = int(input())

This sorts the list

myList.sort()

Assume the number of inputs is odd, the middle element is calculated as

mid = int((count-1)/2)

This prints the middle element

print(myList[mid])

<em>From the complete question. the condition that ends the loop is a negative integer input</em>

You might be interested in
PLS HELP SOON
elixir [45]

Answer:

Explanation:

I will answer Part 1 and you can go on from there.

Decide on a list of items the program will ask the user to input.

Your program should include at least four interactive prompts.

Input from the user should be assigned to variables and used in the story.

"What is your favorite animal?"

Variable: animal

"What word best describes your favorite animal?"

Variable: description

"What does your favorite animal like to eat?"

Variable: food

"Where do your favorite animal live?"

Variable: location

6 0
2 years ago
You work in a customer call center. Martin is on the phone asking about the difference between solid-state drives (SSDs), hybrid
Lostsunrise [7]

Answer:

the hybrids will be better

7 0
3 years ago
Why is it more important now than ever before to know how to evaluate websites and other online sources of information?
mars1129 [50]
If it is a bad website your device could be infected with viruses
5 0
3 years ago
/*
andrew-mc [135]

Answer:

Having tested your source code, I realize that there is nothing to be added or removed from the source code you uploaded as your program works perfectly.

However, I've rearranged properly the lines of the program you uploaded.

See attachment

Explanation:

See Explanation

Download java
5 0
3 years ago
At year end, Clean123 Inc. has 45500 in cash, 55000 in accounts receivable, 54400 in service equipment, 550 in prepaid insurance
Inessa [10]
Oh ok so yea and why you should but I
8 0
3 years ago
Other questions:
  • The addElement operation for the linked implementation must determine the parent of the next node to be inserted. Why?
    5·1 answer
  • Which of the following is an example of a query with an explicit location? Select all that apply. True False [walmart boston], E
    7·2 answers
  • . The toasting cycle of an automatic toaster is started by A. pushing the bread rack down. B. pushing the start button. C. turni
    14·2 answers
  • Write a program that generates a random number between 5 and 15 and asks the user to guess what the number is. If the user’s gue
    5·1 answer
  • An attacker compromises the Washington Post's web server and proceeds to modify the homepage slightly by inserting a 1x1 pixel i
    12·1 answer
  • I need help with this question. its in the photo
    10·1 answer
  • Nia is editing a row in an Access table. The row contains the Pencil icon on the left end of the record
    12·2 answers
  • Write a program named as reverse.c that reads a message, then prints the reversal of the message. The output of the program shou
    7·1 answer
  • What is modern? explain​
    11·1 answer
  • Which software development method uses highly skilled programmers to shorten the development process while producing quality sof
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!