Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54141
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-09-13 15:12 -0700 |
| References | <ef8de6db-5f35-4d07-8306-bcec47b1e69b@googlegroups.com> <75200616-79f5-4088-a967-d3a1381716f2@googlegroups.com> <mailman.304.1378978797.5461.python-list@python.org> |
| Message-ID | <364bcdb3-fdd5-4774-b7d2-040e2ccb4cfd@googlegroups.com> (permalink) |
| Subject | Re: Help please, why doesn't it show the next input? |
| From | William Bryant <gogobebe2@gmail.com> |
On Thursday, September 12, 2013 9:39:33 PM UTC+12, Oscar Benjamin wrote:
> On 12 September 2013 07:04, William Bryant <gogobebe2@gmail.com> wrote:
>
> > Thanks everyone for helping but I did listen to you :3 Sorry. This is my code, it works, I know it's not the best way to do it and it's the long way round but it is one of my first programs ever and I'm happy with it:
>
>
>
> Hi William, I'm glad you've solved your initial problem and I just
>
> wanted to make a couple of comments about how your program could be
>
> simplified or improved. The comments are below.
>
Hello, I've done this so far but why doesn't the mode function work?
'''#*************************************************************************'''
#* 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 = []
Themode = []
#-----# ~~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: ")
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)
if List.count == int(user_inputHMNs):
break
mode()
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: ")
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("Your list -> ", List)
if List.count == int(user_inputHMNn):
break
mode()
def NOS():
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)
def mode():
global NumberOfXItems, Themode
for i in List:
NumberOfXItems.append(i)
NumberOfXItems.append(List.count(i))
Themode = max(NumberOfXItems)
print(Themode)
#-----# ~~The functions which need calling~~ #-----#
# |
# |
# \/
NOS()
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Help please, why doesn't it show the next input? William Bryant <gogobebe2@gmail.com> - 2013-09-10 21:49 -0700
Re: Help please, why doesn't it show the next input? John Gordon <gordon@panix.com> - 2013-09-11 05:11 +0000
Re: Help please, why doesn't it show the next input? William Bryant <gogobebe2@gmail.com> - 2013-09-10 22:39 -0700
Re: Help please, why doesn't it show the next input? Jugurtha Hadjar <jugurtha.hadjar@gmail.com> - 2013-09-11 10:32 +0100
Re: Help please, why doesn't it show the next input? William Bryant <gogobebe2@gmail.com> - 2013-09-11 12:33 -0700
Re: Help please, why doesn't it show the next input? John Gordon <gordon@panix.com> - 2013-09-11 19:46 +0000
Re: Help please, why doesn't it show the next input? Jugurtha Hadjar <jugurtha.hadjar@gmail.com> - 2013-09-12 02:14 +0100
Re: Help please, why doesn't it show the next input? Jugurtha Hadjar <jugurtha.hadjar@gmail.com> - 2013-09-12 02:08 +0100
Re: Help please, why doesn't it show the next input? Dave Angel <davea@davea.name> - 2013-09-11 11:50 +0000
Re: Help please, why doesn't it show the next input? William Bryant <gogobebe2@gmail.com> - 2013-09-11 12:31 -0700
Re: Help please, why doesn't it show the next input? Dave Angel <davea@davea.name> - 2013-09-11 20:32 +0000
RE: Help please, why doesn't it show the next input? "Prasad, Ramit" <ramit.prasad@jpmorgan.com.dmarc.invalid> - 2013-09-11 19:58 +0000
Re: Help please, why doesn't it show the next input? Terry Reedy <tjreedy@udel.edu> - 2013-09-11 17:14 -0400
Re: Help please, why doesn't it show the next input? William Bryant <gogobebe2@gmail.com> - 2013-09-11 23:04 -0700
Re: Help please, why doesn't it show the next input? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-09-12 10:39 +0100
Re: Help please, why doesn't it show the next input? William Bryant <gogobebe2@gmail.com> - 2013-09-13 15:12 -0700
Re: Help please, why doesn't it show the next input? John Gordon <gordon@panix.com> - 2013-09-13 22:41 +0000
Re: Help please, why doesn't it show the next input? MRAB <python@mrabarnett.plus.com> - 2013-09-13 23:48 +0100
Re: Help please, why doesn't it show the next input? William Bryant <gogobebe2@gmail.com> - 2013-09-13 16:34 -0700
csiph-web