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
bezimeni [28]
3 years ago
6

A list is sorted in ascending order if it is empty or each item except the last one is less than or equal to its successor. HERE

S THE CODE:
def isSorted(input_list):
if len(input_list)==0 or len(input_list)==1:
return True
else:
for i in range(len(input_list)):
for j in range(i, len(input_list)):
if input_list[j] < input_list[i]:
return False
return True

def main():
lyst = []
print(isSorted(lyst))
lyst = [1]
print(isSorted(lyst))
lyst = list(range(10))
print(isSorted(lyst))
lyst[9] = 3
print(isSorted(lyst))


if __name__ == "__main__":
main()
Engineering
1 answer:
Free_Kalibri [48]3 years ago
7 0

Using the knowledge of computational language in python it is possible to write a code that writes a list and defines the arrange.

<h3>Writing code in python:</h3>

<em>def isSorted(lyst):</em>

<em>if len(lyst) >= 0 and len(lyst) < 2:</em>

<em>return True</em>

<em>else:</em>

<em>for i in range(len(lyst)-1):</em>

<em>if lyst[i] > lyst[i+1]:</em>

<em>return False</em>

<em>return True</em>

<em>def main():</em>

<em>lyst = []</em>

<em>print(isSorted(lyst))</em>

<em>lyst = [1]</em>

<em>print(isSorted(lyst))</em>

<em>lyst = list(range(10))</em>

<em>print(isSorted(lyst))</em>

<em>lyst[9] = 3</em>

<em>print(isSorted(lyst))</em>

<em>main()</em>

See more about python at brainly.com/question/18502436

#SPJ1

You might be interested in
What is the answer to life the universe and everything <br> (worth 95 points!)
taurus [48]
I would say nothing, time is endless and the cycle of life is endless, not only on earth but almost anywhere, people try to find answers like what’s at the bottom of the ocean and stuff like that but there’s no point in finding out because it has no benefit, life is made for different reasons so there’s not one answer to it
5 0
3 years ago
Read 2 more answers
An automotive piston's connecting rod is 8 inches long. What is the approximate length of this connecting rod in millimeters?
miv72 [106K]
42 millimeters the answer is 42 mill millimeters
7 0
3 years ago
What should you use to keep battery terminals from corroding
Ray Of Light [21]

Answer: Apply battery-terminal grease to the terminals to help prevent corrosion. It's available at any auto parts store and usually comes in a little ketchup-like packet. Another great option is AMSOIL Heavy-Duty Metal Protector. It creates a protective coating on terminals that wards off corrosion.

Explanation:

3 0
3 years ago
Which of the following shot pellets has the smallest diameter?
vitfil [10]
I believe i got this correct when i had an assignment with this question. It should be 7 1/2. B!
5 0
3 years ago
A rigid tank of volume of 0.06 m^3 initially contains a saturated mixture of liquid and vapor of H2O at a pressure of 15 bar and
Serga [27]

Answer:

The total mass in the tank = 0.45524  kg

The amount of heat transferred = 3426.33 kJ

Explanation:

Given that:

The volume of the tank V = 0.06 m³

The pressure of the liquid and the vapor of H2O (p) = 15 bar

The initial quality of the mixture \mathbf{x_{initial} - 0.20}

By applying the energy rate balance equation;

\dfrac{dU}{dt} = Q_{CV} - m_eh_e

where;

m_e =- \dfrac{dm_{CV}}{dt}

Thus, \dfrac{dU}{dt} =Q_{CV} + \dfrac{dm_{CV}}{dt}h_e

If we integrate both sides; we have:

\Delta u_{CV} = Q_{CV} + h _e \int \limits ^2_1 \ dm_{CV}

m_2u_2 - m_1 u_1 = Q_{CV} + h_e (M_2-m_1)  \ \ \ ---  (1)

We obtain the following data from the saturated water pressure tables, at p = 15 bar.

Since:

h_e =h_g

Then: h_g = h_e = 2792.2 \ kJ/kg

v_f = 1.1539 \times 10^{-3} \ m^3 /kg

v_g = 0.1318 \ m^3/kg

Hence;

v_1 = v_f + x_{initial} ( v_g-v_f)

v_1 =  1.1529 \times 10^{-3} + 0.2 ( 0.1318-1.159\times 10^{-3} )

v_1 = 0.02728 \ m^3/kg

Similarly; we obtained the data for u_f \ \& \ u_g from water pressure tables at p = 15 bar

u_f = 843.16 \ kJ/kg\\\\ u_g = 2594.5 \ kJ/kg

Hence;

u_1 = u_f + x_{initial } (u_g -u_f)

u_1 =843.16  + 0.2 (2594.5 -843.16)

u_1 = 1193.428

However; the initial mass m_1 can be calculated by using the formula:

m_1 = \dfrac{V}{v_1}

m_1 = \dfrac{0.06}{0.02728}

m_1 = 2.1994 \ kg

From the question, given that the final quality; x_2 = 1

v_2 = v_f + x_{final } (v_g - v_f)

v_2 = 1.1539 \times 10^{-3} + 1(0.1318 -1.1539 \times 10^{-3})

v_2 = 0.1318 \ m^3/kg

Also;

u_2 = u_f + x_{final} (u_g - u_f)

u_2 = 843.16 + 1 (2594.5 - 843.16)

u_2 = 2594.5 \ kJ/kg

Then the final mass can be calculated by using the formula:

m_2 = \dfrac{V}{v_2}

m_2 = \dfrac{0.06}{0.1318}

m_2 = 0.45524 \ kg

Thus; the total mass in the tank = 0.45524  kg

FInally; from the previous equation (1) above:

m_2u_2 - m_1 u_1 = Q_{CV} + h_e (M_2-m_1)  \ \ \ ---  (1)

Q = (m_2u_2-m_1u_1) - h_e(m_2-m_1)

Q = [(0.45524)(2594.5) -(2.1994)(1193.428)-(2792.2)(0.45524-2.1994)]

Q = [ 1181.12018 - 2624.825543 - (2792.2)(-1.74416 )]

Q = 3426.33 kJ

Thus, the amount of heat transferred = 3426.33 kJ

7 0
3 years ago
Other questions:
  • Consider a magnetic disk consisting of 16 heads and 400 cylinders. This disk has four 100-cylinder zones with the cylinders in d
    7·1 answer
  • Can someone help me on my auto tech worksheet
    13·1 answer
  • What is the relative % change in P if we double the absolute temperature of an ideal gas keeping mass and volume constant?
    14·1 answer
  • Find the requested quantities for the circuit. We used the mesh-current method to identify the meshes. We then identified the me
    5·1 answer
  • If the tank is designed to withstand a pressure of 5 MPaMPa, determine the required minimum wall thickness to the nearest millim
    8·1 answer
  • Plumbing
    12·1 answer
  • Please help fast
    13·1 answer
  • How many spark plugs does a diesel have? How many glow plugs? If you are a redneck/country person dont answer...I wanna see how
    10·2 answers
  • Visual perception is a mental process that is non selective<br> True<br> False
    14·1 answer
  • Flip-flops are normally used for all of the following applications, except ________. logic gates data storage frequency division
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!