Ask Question
5 February, 19:51

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. S
    5 February, 22:48
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers
Sign In
Ask Question