Path: csiph.com!usenet.pasdenom.info!gegeweb.org!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'skip:[ 20': 0.04; 'float': 0.07; 'clean.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sentence': 0.09; 'subject:Help': 0.11; 'python': 0.11; 'project,': 0.12; 'wrote': 0.14; '(about': 0.16; 'collins,': 0.16; 'guess.': 0.16; 'hone': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:Programming': 0.16; 'subtract': 0.16; 'things"': 0.16; 'year,': 0.18; 'bit': 0.19; 'projects,': 0.19; 'work,': 0.20; 'example': 0.22; 'print': 0.22; '(a)': 0.24; 'stick': 0.24; 'header:X-Complaints-To:1': 0.27; 'point': 0.28; 'points': 0.29; 'words': 0.29; 'said,': 0.30; 'skip:( 20': 0.30; "i'm": 0.30; '(which': 0.31; 'gives': 0.31; 'program,': 0.31; 'code': 0.31; 'values.': 0.31; 'this.': 0.32; 'worked': 0.33; '"the': 0.34; 'skip:d 20': 0.34; 'problem': 0.35; 'subject:with': 0.35; 'agree': 0.35; 'late': 0.35; 'test': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'really': 0.36; 'functions.': 0.36; 'in.': 0.36; 'should': 0.36; 'too': 0.37; 'two': 0.37; 'thank': 0.38; 'richard': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'realize': 0.39; 'use.': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'days': 0.60; 'remove': 0.60; 'letters': 0.60; 'negative': 0.60; 'most': 0.60; 'matter': 0.61; "you're": 0.61; 'email addr:gmail.com': 0.63; 'subject:Need': 0.64; 'more': 0.64; 'different': 0.65; 'finish': 0.65; 'levels': 0.65; 'experience.': 0.67; '..........': 0.84; 'avg': 0.84; 'desperate': 0.84; 'min': 0.84; 'subject:Project': 0.84; 'subject:Science': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: Need Help with Programming Science Project Date: Sat, 25 Jan 2014 01:38:42 -0500 (EST) Organization: news.gmane.org References: X-Gmane-NNTP-Posting-Host: dpc6744192012.direcpc.com X-Newsreader: PiaoHong Usenet NewsReaders 1.36 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 56 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390631789 news.xs4all.nl 2837 [2001:888:2000:d::a6]:39279 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64724 kvxdelta@gmail.com Wrote in message: > Alright. I have the code here. Now, I just want to note that the code was not designed to work "quickly" or be very well-written. It was rushed, as I only had a few days to finish the work, and by the time I wrote the program, I hadn't worked with Python (which I never had TOO much experience with anyways) for a while. (About a year, maybe?) It was a bit foolish to take up the project, but here's the code anyways: ......... > > > LPW_Comparisons = [avgLPW_DJ_EXAMPLE, avgLPW_SUZC_EXAMPLE, avgLPW_SUZC_EXAMPLE] > avgLPW_Match = min(LPW_Comparisons) > > if avgLPW_Match == avgLPW_DJ_EXAMPLE: > DJMachalePossibility = (DJMachalePossibility+1) > > if avgLPW_Match == avgLPW_SUZC_EXAMPLE: > SuzanneCollinsPossibility = (SuzanneCollinsPossibility+1) > > if avgLPW_Match == avgLPW_RICH_EXAMPLE: > RichardPeckPossibility = (RichardPeckPossibility+1) > > AUTHOR_SCOREBOARD = [DJMachalePossibility, SuzanneCollinsPossibility, RichardPeckPossibility] > > #The author with the most points on them would be considered the program's guess. > Match = max(AUTHOR_SCOREBOARD) > > print AUTHOR_SCOREBOARD > > if Match == DJMachalePossibility: > print "The author should be D.J. Machale." > > if Match == SuzanneCollinsPossibility: > print "The author should be Suzanne Collins." > > if Match == RichardPeckPossibility: > print "The author should be Richard Peck." > > > ------------------------------------------------------------------------------ > Hopefully, there won't be any copyright issues. Like someone said, this should be fair use. The problem I'm having is that it always gives Suzanne Collins, no matter what example is put in. I'm really sorry that the code isn't very clean. Like I said, it was rushed and I have little experience. I'm just desperate for help as it's a bit too late to change projects, so I have to stick with this. Also, if it's of any importance, I have to be able to remove or add any of the "average letters per word/average letters per sentence/average words per sentence things" to test the program at different levels of strictness. I would GREATLY appreciate any help with this. Thank you! > 1. When you calculate averages, you should be using floating point divide. avg = float (a) / b 2. When you subtract two values, you need an abs, because otherwise min () will hone in on the negative values. 3. Realize that having Match agree with more than one is not that unlikely. 4. If you want to vary what you call strictness, you're really going to need to learn about functions. -- DaveA