I need to make an interactive program in Python that will start by asking the user to enter a list of numbers and then it will display the following menu.

1-Find The Maximum
2-Find The Minimum
3-Find The Average
4-Exit
Please Enter Your selection

Your program will accept a number from the user and perform the task corresponding to that number. After performing the required task, the program will continue to ask to perform other tasks and display the menu. This program will end only when the user enters 4.

We will not do your homework for you. Show us an effort first, if you have problems we can help.

We will not do your homework for you. Show us an effort first, if you have problems we can help.

Here's what I have.

def main ():
    sum=0.0
    count=0
    x = input("Enter a number")
     
     for i in range(x):
         n = input ("Enter a number")
         sum = sum + n
    print "\nThe average of the numbers is",sum / n

for i in range(99):   # need to read 99 more numbers and update the min if we read a number smaller than current value of min
       num = input("Enter next number: ")
       sum += num
       if num < min:
             min = num

for i in range(99):   # need to read 99 more numbers and update the min if we read a number smaller than current value of min
       num = input("Enter next number: ")
       sum += num
       if num > min:
             max = num
print "The smallest number was %f." % min
print 'The average is %f.' % (sum/100.0)

I have awhole lot of errors thought, plus I don't know how to make the box.

You will be well served to think about the program flow first. Here are some questions whose answers may help you write the code you need.

  • How does the program know how many numbers to work with?
    • is the number specified by interaction?
    • is the number specified in the code?
  • How is the data made available?
    • Is it entered by the user? If so: one number at a time? (seems awkward)
    • Is it in a file somewhere? If so, how does the program know which file?
    • Is it hard coded in the program text?
  • Assuming the data is not hard coded, how do I handle it?
    • Do I read it into a data structure, then work with that structure?
    • Do I handle each item as it is seen, saving only the needed information?
  • How are the results given to the user?
    • Written to the console?
    • Written to a file?
    • In a GUI of some kind?

I do not see requirement of writing your own sum, min and max; so you better concentrate finding better system of taking any number of user input. Do not worry about maths if you are really allowed to use standard functions, but input values to list by apppend method. You should take numbers until empty line or 'q', I suggest.

I see some nice keywords in the question....

I need to make an interactive program in Python that will start by asking the user to enter a list of numbers and then it will display the following menu.

1-Find The Maximum -- seem like some functions
2-Find The Minimum
3-Find The Average
4-Exit
Please Enter Your selection

Your program will accept a number from the user and perform the task corresponding to that number. After performing the required task, the program will continue to ask to perform other tasks and display the menu. This program will end only when the user enters 4.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.