On Friday, September 20, 2013 11:09:03 AM UTC+12, Ian wrote:
> On Thu, Sep 19, 2013 at 1:22 PM, William Bryant <gogobe...@gmail.com> wrote:
> 
> > It was the other functions above it. Thanks. but I tried to do the while
> 
> > loop - I don't think I did it right, I am novice in python and I am 13 years
> 
> > old.
> 
> 
> 
> It should be structured like this:
> 
> 
> 
>     while True:
> 
>         answer = input("Enter yes/no:")
> 
>         if answer in ('y', 'yes', 'new list'):
> 
>             do_yes_stuff()
> 
>             break
> 
>         elif answer in ('n', 'no', 'close'):
> 
>             do_no_stuff()
> 
>             break
> 
>         else:
> 
>             print("Please enter y or n.")
> 
> 
> 
> If they answer 'yes' or 'no', then the break statement breaks out of
> 
> the while loop.  Otherwise the while loop continues from the top and
> 
> asks them again.

Thanks a lot! I have one more question, is there any way I can make my program 
work on android tablets and ipads? Because I'd like to use it in school because 
we are learning statistics and we are allowed our devices in school.


'''**************************************************************************'''
#* Name:        Mode-Median-Mean Calculator                                   *#
#*                                                                            *#
#* Purpose:     To calculate the mode, median and mean of a list of numbers   *#
#*              and the mode of a list of strings because that is what we are *#
#*              learning in math atm in school :P                             *#
#*                                                                            *#
#* Author:      William Bryant                                                *#
#*                                                                            *#
#* Created:     11/09/2013                                                    *#
#*                                                                            *#
#* Copyright:   (c) William 2013                                              *#
#*                                                                            *#
#* Licence:     IDK :3                                                        *#
'''**************************************************************************'''



#-----#                   ~~Import things I am using~~                   #-----#

#         |
#        |
#       \/

import time
import itertools



#-----#        ~~Variables that I am using, including the list.~~        #-----#

#         |
#        |
#       \/

List = []
NumberOfXItems = []

#-----#                   ~~Functions that I am using.~~                 #-----#

#         |
#        |
#       \/

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:  ")
    if user_inputHMNs == "restart":
        NOS()
    time.sleep(1.5)
    TheStr = int(user_inputHMNs)
    for i in range(TheStr):
        List_input = input("Enter your strings. (One in each input field):  \n")
        if List_input == "restart":
            NOS()
        List.append(List_input)
        
print("############################################################################\nThis
 is the amount of strings you are using in your list:", user_inputHMNs)
        print("and this is how much space you have left in your list for 
strings:", int(user_inputHMNs) - len(List), 
"\n################################################################################\n")
        print("Your list -> ", List)
        print("(0 is the first number in your list)\n")
        for i in range(len(List)):
            print("number " + str(i) + ": " + str(List[i]))
        print("\n*Mode*:", mode())
        print("*Median*:",  "There is no median for a list of strings - Only 
mode")
        print("*Mean*:",    "There is no mean for a list of strings - Only 
mode")
        if int(user_inputHMNs) - len(List) == 0:
            init()


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:  ")
    if user_inputHMNn == "restart":
        NOS()
    time.sleep(1.5)
    TheNum = int(user_inputHMNn)
    for i in range(TheNum):
        List_input = input("Enter your numbers. (One in each input field):  \n")
        List_input = int(List_input)
        if List_input == "restart":
            NOS()
        List.append(List_input)
        
print("############################################################################\nThis
 is the amount of numbers you are using in your list:", user_inputHMNn)
        print("and this is how much space you have left in your list for 
numbers:", int(user_inputHMNn) - len(List), 
"\n################################################################################\n")
        print("Your list -> ", List)
        print("(0 is the first number in your list)\n")
        for i in range(len(List)):
            print("number " + str(i) + ": " + str(List[i]))
        print("\n*Mode*:", mode())
        print("*Median*:",  "<Coming soon!>")
        print("*Mean*:",    mean(), "\n")
        if int(user_inputHMNn) - len(List) == 0:
            init()

def NOS():
    print("Loading...\n")
    time.sleep(2.5)
    while True: # Loops forever (until the break)
        answer = input("Does your list contain a number or a string?  \nEnter: 
")
        answer = answer.lower()
        if answer in ("string", "str", "s"):
            HMNs()
            break
        elif answer in ("number", "num", "n", "int"):
            HMNn()
            break
        elif answer in ("quit", "q"):
            break  # Exits the while loop
        else:
            print("You did not enter a valid field, :P Sorry.  \nEnter: ")
    time.sleep(1.5)
    if answer == "restart":
        NOS()
def mean():
    thesum = sum(List)
    amount = len(List)
    themean = thesum / amount
    return themean

def mode():
    max_occurrences = 0
    themode = None
    for i in List:
        thecount = List.count(i)
        if thecount > max_occurrences:
            max_occurrences = thecount
            themode = i
    return themode

def median():
    pass

def init():
    print("""

    ~~~~~~~~~~~~~~~~

    Cacluation DONE!

    ~~~~~~~~~~~~~~~~

    """)
    while "lol" == "lol":
        restart = input("\nEnter yes if you want to make a new list and no if 
you want to close the program (yes/no):  ")
        if restart in ('y', 'yes', 'new list'):
            print("You want make a new list...\n")
            time.sleep(1)
            NOS()
            break
        elif restart in ('n', 'no', 'close'):
            for i in range(6):
                print("""Goodbye! Thanks you for using my program!
                         - William Bryant (AKA gogobebe2)""")
                time.sleep(1)
            quit()
        else:
            print("type y or n")
            time.sleep(0.5)
            init()
#-----#               ~~The functions which need calling~~               #-----#

#         |
#        |
#       \/

NOS()



Thanks again - Will 

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to