Question

p p+ 1 endwhile 2. Design a program that allows a user to enter any quantity of numbers until a negative number is entered. T

must be in python

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

# set repeat to true, variable used for looping
repeat = True
count = 0
lowest = -1
highest = -1
# run a loop as long as repeat is true
while repeat:
    # read a number from the user
    n = int(input("Enter a number (negative number to quit):"))
    # set repeat to false to terminate the loop if a negative number is entered
    if(n < 0):
        repeat = False
    # proceed if positive number is entered
    else:
        # if the number entered is first number, assume it be highest and lowest
        if (count == 0):
            lowest = n
            highest = n
        # if not the first number, then find the highest and lowest numbers
        else:
            # if the number is less than lowest store n in lowest
            if(n < lowest):
                lowest = n
            # if the number is greater than highest store n in highest
            if(n > highest):
                highest = n
        # increment the count of numbers read
        count = count + 1
# if no numbers are entered display appropriate message
if(count == 0):
    print("No numbers entered.")
# else display the highest and lowest number
else:
    print("\nThe highest number entered is: " + str(highest))
    print("The lowest number entered is: " + str(lowest))

              

Output:

Python 3.64 Shell File Edit She Debug Options Window Help Python 3.6.4 (V3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32

Program Screenshot:

Highestlowest.py - C:/Users/Madhuri/AppData/Local/Programs/Python/Python36-32/Highe. File Edit Format Run Options Window Help

Let me know if you have any concerns with the above solution.

Add a comment
Know the answer?
Add Answer to:
must be in python p p+ 1 endwhile 2. Design a program that allows a user...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C++ 2. Write a program that allows the user to enter a series of positive...

    In C++ 2. Write a program that allows the user to enter a series of positive numbers between 1 and 100 and displays the smallest and largest of the numbers entered. The program should not store the numbers that were entered, only keep track of the smallest and largest ones. The program should continue accepting numbers until the value 0 is entered and then display the results. If a number out of range is entered, tell the user it is...

  • a. Design the logic for a program that allows a user to enter 12 numbers, then...

    a. Design the logic for a program that allows a user to enter 12 numbers, then displays them in the reverse order of entry. b. Modify the reverse-display program so that the user can enter any amount of numbers up to 12 until a sentinel value is entered. ( I really could use more of a pseudocode rather than actual code. also an explanation of each step. The answer I got last time was just c++ code that including a...

  • Design the logic for a program that allows the user to enter a maximum of 10...

    Design the logic for a program that allows the user to enter a maximum of 10 numbers. If the use enters a -1 the input loop stops early. The value -1 is not data but a quit flag value that is not entered into the array. Then the program displays the count of the numbers entered and numeric average of the numbers (not including the -1 of course). After display the average of all the entered numbers, the program will...

  • Design the logic for a program that allows a user to enter 10 numbers, then displays...

    Design the logic for a program that allows a user to enter 10 numbers, then displays the element number, value in the element, and its squared. The language is Python

  • Write a PYTHON program that allows the user to navigate the lines of text in a...

    Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...

  • Design a program that asks the user to enter a series of 20 numbers. The program...

    Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in the array and then display the following data: The lowest number in the array The highest number in the array The total of the number in the array The average of the numbers in the array PLEASE GIVE THE PSEUDOCODE AND CODE IN C PROGRAMMING

  • in Python: Write a program that allows the user to enter a number between 1-5 and...

    in Python: Write a program that allows the user to enter a number between 1-5 and returns an animal fact based on what the user entered. The program should 1. Continue to run until the user enters “quit” to terminate the program, and 2. Validate the user’s input (the only acceptable input is 1, 2, 3, 4, 5 or “quit”). You can use the following animal facts: An octopus is a highly intelligent invertebrate and a master of disguise. Elephants...

  • 2) Largest and Smallest Design a program with a loop that lets the user enter a...

    2) Largest and Smallest Design a program with a loop that lets the user enter a series of numbers. The user should enter-99-99 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers entered. a) Use a Do-Until Loop

  • Design the logic for a program that allows a user to enter 10 numbers, then displays...

    Design the logic for a program that allows a user to enter 10 numbers, then displays all of the numbers, the sum and average of the numbers. (Use array and loop.) the pseudocode in python please

  • Write a Python program that allows the user to enter the total rainfall for each of...

    Write a Python program that allows the user to enter the total rainfall for each of 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest rainfall amounts. Data: January: 8.9 inches February: 11.1 inches March: 13.4 inches April: 6.9 inches May: 8.7 inches June: 9.1 inches July: 15.9 inches August: 4.4 inches September: 3.1 inches October: 5.6 inches November: 7.8...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT