HW #4

?Hi Professor,


I was wondering, if you get a chance, if you could look at task_05.py in GitHub. I get an error message, invalid syntax saying I can't print MATCHUPS. I am sure I am doing something wrong, but I am not sure what.


Also, I would like to be able to make the study sessions, however they take place between 2-3 AM my time, as I am living in Paris until the end of October. Is there any possibility of them being recorded?


Sam

________________________________
From: Chad Heuschober <notifications@github.com>
Sent: Tuesday, September 23, 2014 8:52 PM
To: is210-2014-fall-02/is210_lesson_04
Cc: samuel.cohen-devries@spsmail.cuny.edu
Subject: Re: [is210_lesson_04] HW #4 (#10)


In task_01.py:

> +print "\n *** max number of words in a line = " + str(MAXIMUM_WORDS)
> +
> +import data
> +SHAKE1 = data.SHAKESPEARE.split("\n")
> +MINIMUM_WORDS = MAXIMUM_WORDS
> +for line in SHAKE1:
> +    y = (line).split(" ")
> +    if len(y) < MINIMUM_WORDS:
> +        MINIMUM_WORDS = len(y)
> +print "\n *** min number of words in a line = " + str(MINIMUM_WORDS)
> +
> +SHAKE2 = data.SHAKESPEARE.split()
> +AVERAGE_WORDS = float(len(SHAKE2) / len(SHAKE1))
> +
> +NUM_CRISPIAN = data.SHAKESPEARE.count("Crispin")
> +print NUM_CRISPIAN


You can totally do this all in one loop. Consider the following starter:

TOTAL_WORDS = 0
NUM_LINES = 0
MAXIMUM_WORDS = 0
MINIMUM_WORDS = 0
for LINE in data.SHAKESPEARE.split('\n'):
    LINES += 1
    WORDS = LINE.split()
    WORD_CT = len(WORDS)
    if WORD_CT < MINIMUM_WORDS or MINIMUM_WORDS is None:  # the none check here is unique to min
        MINIMUM_WORDS = WORD_CT

    # repeat the same idea for max

    # check for crispian using `in`

    # increment TOTAL_WORDS by += WORD_CT

# calculate average after the loop has run


-
Reply to this email directly or view it on GitHub<https://github.com/is210-2014-fall-02/is210_lesson_04/pull/10/files#r17930435>.