Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54143
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'author:': 0.03; 'else:': 0.03; 'elif': 0.05; 'string.': 0.05; 'list?': 0.07; 'variables': 0.07; 'exits': 0.09; 'parameter': 0.09; 'strings.': 0.09; 'subject:Help': 0.11; 'def': 0.12; 'bug': 0.12; 'benjamin': 0.16; 'calculator': 0.16; 'collections': 0.16; 'field):': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'integer,': 0.16; 'integer.': 0.16; 'itertools': 0.16; 'list)': 0.16; 'loops': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'mode,': 0.16; 'simplified': 0.16; 'subject:show': 0.16; 'true:': 0.16; 'using,': 0.16; 'thursday,': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'code,': 0.22; 'input': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; "aren't": 0.24; 'comparing': 0.24; 'number)': 0.24; 'initial': 0.24; 'math': 0.24; "i've": 0.25; '(see': 0.26; 'header:In-Reply- To:1': 0.27; 'function': 0.29; '(c)': 0.29; "doesn't": 0.30; 'field,': 0.30; 'list:': 0.30; 'mode': 0.30; 'subject:please': 0.30; "i'm": 0.30; 'getting': 0.31; 'comments': 0.31; 'decimal': 0.31; 'occurs': 0.31; 'subject:next': 0.31; 'class': 0.32; 'everyone': 0.33; 'subject:the': 0.34; 'could': 0.34; 'problem': 0.35; 'but': 0.35; 'done': 0.36; 'method': 0.36; 'thanks': 0.36; 'subject:?': 0.36; 'list': 0.37; 'work?': 0.38; 'to:addr:python- list': 0.38; '12,': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'skip:n 30': 0.60; 'break': 0.61; 'numbers': 0.61; 'name:': 0.61; "you're": 0.61; 'first': 0.61; 'times': 0.62; "you've": 0.63; 'maximum': 0.63; 'skip:n 10': 0.64; 'school': 0.64; 'here': 0.66; 'header:Reply-To:1': 0.67; 'atm': 0.68; 'helping': 0.70; 'below.': 0.71; 'reply-to:no real name:2**0': 0.71; 'william': 0.81; 'glad': 0.83; 'entry,': 0.84; 'improved.': 0.84; 'median': 0.84; 'oscar': 0.84; 'reply- to:addr:python.org': 0.84; "skip:' 80": 0.84; 'true!': 0.84; 'william,': 0.84; 'sorry.': 0.91; '2013': 0.98 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=I5lcGrQg c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=0kkAYlmtguIA:10 a=GWQ-Y4Bi3gUA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=ZFnUJlagkAkA:10 a=pGLkceISAAAA:8 a=Lq0acc4o9kXBv9DbhXcA:9 a=pKrrvJyQktZoBvsM:21 a=Q6QZtRM_Lreyuku4:21 a=wPNLvfGTeEIA:10 a=MSl-tDqOz04A:10 |
| X-AUTH | mrabarnett:2500 |
| Date | Fri, 13 Sep 2013 23:48:49 +0100 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Help please, why doesn't it show the next input? |
| References | <ef8de6db-5f35-4d07-8306-bcec47b1e69b@googlegroups.com> <75200616-79f5-4088-a967-d3a1381716f2@googlegroups.com> <mailman.304.1378978797.5461.python-list@python.org> <364bcdb3-fdd5-4774-b7d2-040e2ccb4cfd@googlegroups.com> |
| In-Reply-To | <364bcdb3-fdd5-4774-b7d2-040e2ccb4cfd@googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | python-list@python.org |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.365.1379112525.5461.python-list@python.org> (permalink) |
| Lines | 152 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1379112525 news.xs4all.nl 15970 [2001:888:2000:d::a6]:39989 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:54143 |
Show key headers only | View raw
On 13/09/2013 23:12, William Bryant wrote:
> 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.~~ #-----#
>
> # |
> # |
> # \/
>
Global variables and no parameter passing: yuck! :-)
> List = []
> NumberOfXItems = []
> Themode = []
>
> #-----# ~~Functions that I am using.~~ #-----#
>
> # |
> # |
> # \/
>
Your function names aren't meaningful.
> 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)
This variable is an integer, yet it's called 'TheStr'.
> 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)
Here you're comparing the list's .count method with an integer. It'll
never be true!
> 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)
The same bug as above:
> 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:
Here you're appending an item and then the number of times that the item
occurs:
> NumberOfXItems.append(i)
> NumberOfXItems.append(List.count(i))
Here you're getting the maximum entry, be it an item or the number of
times an item occurs (see above). Have a look at the Counter class from
the collections module:
> 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