Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64724
| From | Dave Angel <davea@davea.name> |
|---|---|
| Subject | Re: Need Help with Programming Science Project |
| Date | 2014-01-25 01:38 -0500 |
| Organization | news.gmane.org |
| References | <b1831c17-d9f9-4576-9488-7463e76ccf3b@googlegroups.com> <ba404807-08a2-48e6-bfa2-dd8ea8d1acca@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5966.1390631789.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Need Help with Programming Science Project theguy <kvxdelta@gmail.com> - 2014-01-24 02:05 -0800
Re: Need Help with Programming Science Project Peter Otten <__peter__@web.de> - 2014-01-24 12:07 +0100
Re: Need Help with Programming Science Project bob gailer <bgailer@gmail.com> - 2014-01-24 18:38 -0500
Re: Need Help with Programming Science Project Chris Angelico <rosuav@gmail.com> - 2014-01-25 11:34 +1100
Re: Need Help with Programming Science Project Ben Finney <ben+python@benfinney.id.au> - 2014-01-25 11:59 +1100
Re: Need Help with Programming Science Project Roy Smith <roy@panix.com> - 2014-01-24 20:38 -0500
Re: Need Help with Programming Science Project Terry Reedy <tjreedy@udel.edu> - 2014-01-24 20:10 -0500
Re: Need Help with Programming Science Project kvxdelta@gmail.com - 2014-01-24 18:42 -0800
Re: Need Help with Programming Science Project Rustom Mody <rustompmody@gmail.com> - 2014-01-24 19:06 -0800
Re: Need Help with Programming Science Project theguy <kvxdelta@gmail.com> - 2014-01-24 20:58 -0800
Re: Need Help with Programming Science Project Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-01-25 20:30 +1300
Re: Need Help with Programming Science Project Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-25 11:31 +0000
Re: Need Help with Programming Science Project Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-25 09:42 -0500
Re: Need Help with Programming Science Project Rustom Mody <rustompmody@gmail.com> - 2014-01-25 08:15 -0800
Re: Need Help with Programming Science Project Dave Angel <davea@davea.name> - 2014-01-25 01:38 -0500
Re: Need Help with Programming Science Project Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-01-25 20:25 +1300
Re: Need Help with Programming Science Project alex23 <wuwei23@gmail.com> - 2014-01-28 17:31 +1000
csiph-web