Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Python HMWK Help?

  1. #11

    Joined
    Apr 2020
    Posts
    24
    Thanks
    8
    Thanked
    12/8
    Mentioned
    1 time
    Time Online
    9h 24m
    Avg. Time Online
    N/A
    I'm back with more Python hmwk ;_;

    I feel like I have some of the right pieces, but it's scattered and in the wrong order. I know that some pieces are incorrect (lines 6-10) or duplicated because I copied over some code from a previous assignment I did that had some lines I needed, but with different outputs. I need help in organizing these functions in order to reflect the assignment instructions. I always seem to get pieces of it, but mess up with putting things together correctly. Thanks in advance to any input you guys give and also thanks for your patience with my slow comprehension of Python <3

    (you need an account to see links)

  2. #12

    Joined
    Apr 2020
    Posts
    24
    Thanks
    8
    Thanked
    12/8
    Mentioned
    1 time
    Time Online
    9h 24m
    Avg. Time Online
    N/A
    Oh and the txt file we're pulling from has a bunch of "X-DSPAM-Confidence: 0.#####" lines that we're referring from along with other random text lines.

  3. #13

    Joined
    May 2016
    Posts
    217
    Userbars
    9
    Thanks
    437
    Thanked
    229/96
    DL/UL
    17/0
    Mentioned
    18 times
    Time Online
    7d 14h 56m
    Avg. Time Online
    3m
    Okay so a few pointers to give you some food for thought.

    1) Sounds like you need to extract each of the floating point numbers referred to in ## in each line of the source file being read in that matches this format "X-DSPAM-Confidence: #.#####"

    2) So, during the loop when it finds that match type, then the program should keep track of the total addition of those numbers found to date

    3) After the loop that total number should be divided by the number of times those lines were found, which would give you the average across all the numbers found that match that format

    4) Keep in mind how Python does blocks, is your FOR loop working correctly the way it is? Why is there a total=0 on line 11, isn't that going to reset the value of total after the loop? Don't you want to add the value to the "total" inside the loop? Also why is count=0 in line 12 that is just going to reset the count on the loop too.

    Have a think of it and report back with what you tried out

  4. The Following 2 Users Say Thank You to aaronsd For This Useful Post:

    linttastic (06-27-2020),Zachafer (06-29-2020)

  5. #14

    Joined
    Apr 2020
    Posts
    24
    Thanks
    8
    Thanked
    12/8
    Mentioned
    1 time
    Time Online
    9h 24m
    Avg. Time Online
    N/A
    Quote Originally Posted by aaronsd View Post
    Okay so a few pointers to give you some food for thought.

    1) Sounds like you need to extract each of the floating point numbers referred to in ## in each line of the source file being read in that matches this format "X-DSPAM-Confidence: #.#####"

    2) So, during the loop when it finds that match type, then the program should keep track of the total addition of those numbers found to date

    3) After the loop that total number should be divided by the number of times those lines were found, which would give you the average across all the numbers found that match that format

    4) Keep in mind how Python does blocks, is your FOR loop working correctly the way it is? Why is there a total=0 on line 11, isn't that going to reset the value of total after the loop? Don't you want to add the value to the "total" inside the loop? Also why is count=0 in line 12 that is just going to reset the count on the loop too.

    Have a think of it and report back with what you tried out
    Hey thanks for breaking it down for me! I got it set up properly after I looked over the FOR loop. Later, it turned out I had my float set up wrong that it ended up returning a nan error. Well all done now anyway, phew! Thanks again for helping! I appreciate having someone else just sort of re-read it for me so I can make sure I understand the assignment at least haha.

  6. The Following User Says Thank You to linttastic For This Useful Post:

    aaronsd (06-27-2020)

  7. #15

    Joined
    May 2016
    Posts
    217
    Userbars
    9
    Thanks
    437
    Thanked
    229/96
    DL/UL
    17/0
    Mentioned
    18 times
    Time Online
    7d 14h 56m
    Avg. Time Online
    3m
    Quote Originally Posted by linttastic View Post
    Hey thanks for breaking it down for me! I got it set up properly after I looked over the FOR loop. Later, it turned out I had my float set up wrong that it ended up returning a nan error. Well all done now anyway, phew! Thanks again for helping! I appreciate having someone else just sort of re-read it for me so I can make sure I understand the assignment at least haha.
    Glad to know you sorted it out always happy to discuss and help!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •