How do I calculate a mean with python?

MRAB python at mrabarnett.plus.com
Tue Sep 17 17:26:58 EDT 2013


On 17/09/2013 21:10, William Bryant wrote:
> Ok I think I've fixed it thanks I read everything.
>
[snip]
>
> def HMNs():
>      global TheStr, user_inputHMNs, List_input, List
>      user_inputHMNs = input("You picked string. This program cannot calculate the mean or median, but it can calculate the mode. :D  How many strings are you using in your list? (Can not be a decimal number)  \nEnter:  ")

This line doesn't do anything:

>      user_inputHMNs
>      time.sleep(1.5)
>      TheStr = int(user_inputHMNs)
>      for i in range(TheStr):
>          List_input = input("Enter your strings. (One in each input field):  ")
>          List.append(List_input)
>          print("Your list -> ", List)

List.count is a method; it will never equal an integer:

>          if List.count == int(user_inputHMNs):
>              break
>          print("\n*Mode*:", mode())
>          print("*Median*:",  "<Coming soon!>\n")
>          print("*Mean*:",    mean())
>
> def HMNn():
>      global TheNum, user_inputHMNn, List_input, List
>      user_inputHMNn = input("You picked number. :D How many numbers are you using in your list? (Can not be a decimal number) \nEnter:  ")

This line doesn't do anything:

>      user_inputHMNn
>      time.sleep(1.5)
>      TheNum = int(user_inputHMNn)
>      for i in range(TheNum):
>          List_input = input("Enter your numbers. (One in each input field):  ")
>          List_input = int(List_input)
>          List.append(List_input)
>          print("\nYour list -> ", List)

List.count is a method; it will never equal an integer:

>          if List.count == int(user_inputHMNn):
>              break
>          print("\n*Mode*:", mode())
>          print("*Median*:",  "<Coming soon!>")
>          print("*Mean*:",    mean())
>
[snip]




More information about the Python-list mailing list