Ask Question
20 September, 01:54

Assign True to the variable is_ascending if the list numbers is in ascending order (that is, if each element of the list is greater than or equal to the previous element in the list). Otherwise, assign False with is_ascending.

+2
Answers (1)
  1. 20 September, 04:50
    0
    The question seem incomplete as the list is not given and the programming language is not stated;

    To answer this question, I'll answer this question using Python programming language and the program will allow user input.

    Input will stop until user enters 0

    The program is as follows

    newlist = []

    print ("Input into the list; Press 0 to stop")

    userinput = int (input ("User Input:"))

    while not userinput = = 0:

    newlist. append (userinput)

    userinput = int (input ("User Input:"))

    is_ascending = "True"

    i = 1

    while i < len (newlist):

    if (newlist[i] < newlist[i - 1]):

    is_ascending = "False"

    i + = 1

    print (newlist)

    print (is_ascending)

    Explanation:

    This line declares an empty list

    newlist = []

    This line prompts gives instruction to user on how to stop input

    print ("Input into the list; Press 0 to stop")

    This line prompts user for input

    userinput = int (input ("User Input:"))

    This next three lines takes input from the user until the user enters 0

    while not userinput = = 0:

    newlist. append (userinput)

    userinput = int (input ("User Input:"))

    The next line initialized "True" to variable is_ascending

    is_ascending = "True"

    The next 5 line iterates from the index element of the list till the last to check if the list is sorted

    i = 1

    while i < len (newlist):

    if (newlist[i] < newlist[i - 1]):

    is_ascending = "False"

    i + = 1

    The next line prints the list

    print (newlist)

    The next line prints the value of is_ascending

    print (is_ascending)
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Assign True to the variable is_ascending if the list numbers is in ascending order (that is, if each element of the list is greater than or ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers