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
Help!!! Who is this? Who is it from?
sergey [27]
Show: Dragon Ball Super
Character: Vegito
8 0
4 years ago
Read 2 more answers
It can be hard to get close enough to photograph animals in the wild true or false
marysya [2.9K]

Answer:

True

Explanation:

8 0
3 years ago
Read 2 more answers
I need answer pooooooo​
lara [203]
Read the instructions right, youll get ir done
7 0
3 years ago
_______ is defined as a state of periodic or chronic impairment detrimental to the individual and society.
aleksandrvk [35]
I believe the answer is addiction. 
8 0
4 years ago
Read 2 more answers
Relational operators allow you to ________ numbers
Sonja [21]

Relational operators allow an end user to <u>compare</u> numbers.

<h3>What are relational operators?</h3>

Relational operators can be defined as a programming language construct which allows an end user to compare both numbers and char values.

Also, it can be used to determine whether one number is less than (<), greater than (>), equal to (=), or not equal to another.

This ultimately implies that, relational operators allow an end user to <u>compare</u> numbers.

Read more on relational operators here: brainly.com/question/14995818

#SPJ1

6 0
2 years ago
Other questions:
  • Individually or in a group find as many different examples as you can of physical controls and displays.a. List themb. Try to gr
    15·1 answer
  • What is the definition of legal intrusion
    14·1 answer
  • What setting must be enabled to view data in Demographics and Interests Reports? Content Grouping Advertising features User perm
    13·1 answer
  • Jane, a marketing manager for the Grocery SuperStore retail chain, fired up a computer program that gave her ready access to inf
    6·1 answer
  • How is a composite key implemented in a relational database model?
    11·1 answer
  • Various units used to measure computer memory
    13·1 answer
  • What does a capitalist economy allow people to do?
    11·2 answers
  • Assuming dataFile is an ofstream object associated with a disk file named payroll.dat, which of the following statements would w
    9·1 answer
  • State the name of each of the storage devices described below.
    14·1 answer
  • Most presentations use text:
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!