Hello all,

I am very new to programming and my teacher has started us on Python. While I think Python would be a great choice for most people, I have come to the conclusion that I am not cut out for programming. I am finding it very difficult, though fun. I have to have 2 tiny programs turned in in about 12 hours and have no idea what I am doing.

Here is what I have to do:
A. Build a module that contains three functions that do the following:
Compute the average of a list of numbers
Finds the statistical median value of a list of numbers
Finds the mode of a list of numbers

B. Write a program that allows you to do the following five operations:
Prompt the user to input a list of numbers (Hint: be sure to have a way for the user to indicate that they are done finished providing the list of numbers)
Open a file that contains a list of numbers
Compute the average, statistical median, and mode of the list of numbers
Asks the user whether they want to see the answers and if the answer is yes, opens the file and displays the numbers.

While I am not asking for a handout, because learning on my own is the only way to learn, I am having a very hard time with this. I believe that I can handle part A, but when I put it in to B is when I have trouble. I can not figure out how to make it do the math for both lists, and I do not know how to open, save, or write to files. Any nudging in the right direction would be greatly appreciated.

Thanks,

P

Some basics:

To calculate the mean (average), add up all the terms (numeric values) in the list, and then divide by the number of terms in the list.

If the number of terms is odd, then the median is the value of the term in the middle of the sorted list. If the number of terms is even, then the median is the average of the two terms in the middle of the sorted list.

The mode of a list of numbers is the value of the term that occurs the most often. A list can have several modes.

Some hints:

To sum up all the numeric values in a list my_list use sum(my_list)

To find the number of values in the list use len(my_list)

To sort a list in place use my_list.sort()

To check if an integer number n is odd use (n & 1). This evaluates to 1 (True) if n is odd, else to 0 (False).

Use my_list.count(n) to find how many times n appears in the list.

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.