Ask Question
23 December, 18:37

Create a program that will find and display the largest of a list of positive numbers entered by the user. The user should indicate that he/she has finished entering numbers by entering a 0.

+5
Answers (1)
  1. 23 December, 19:02
    0
    This program is written using Python Programming language,

    The program doesn't make use of comments (See explanation section for line by line explanation)

    Program starts here

    print ("Enter elements into the list. Enter 0 to stop")

    newlist = []

    b = float (input ("User Input: "))

    while not b==0:

    newlist. append (b)

    b = float (input ("User Input: "))

    newlist. sort ()

    print ("Largest element is:", newlist[-1])

    Explanation:

    This line gives the user instruction on how to populate the list and how to stop

    print ("Enter elements into the list. Enter 0 to stop")

    This line creates an empty list

    newlist = []

    This line enables the user to input numbers; float datatype was used to accommodate decimal numbers

    b = float (input ("User Input: "))

    The italicized gets input from the user until s/he enters 0

    while not b==0:

    newlist. append (b)

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

    This line sorts the list in ascending order

    newlist. sort ()

    The last element of the sorted list which is the largest element is printed using the next line

    print ("Largest element is:", newlist[-1])
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Create a program that will find and display the largest of a list of positive numbers entered by the user. The user should indicate that ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers