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

Thread: Python HMWK Help?

  1. #11
    linttastic's Avatar
    Join Date
    Apr 2020
    Gender
    Location
    California
    Age
    28
    Posts
    24
    Userbars
    0
    Thanks
    8
    Thanked 12 Times in 8 Posts


    Downloads
    0
    Uploads
    0
    Mentioned
    1 Post(s)
    Time Online
    9 h 24 m
    Avg. Time Online
    6 m
    Rep Power
    1
    Gamer IDs

    PSN ID: grotle_24
    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


  2. #12
    linttastic's Avatar
    Join Date
    Apr 2020
    Gender
    Location
    California
    Age
    28
    Posts
    24
    Userbars
    0
    Thanks
    8
    Thanked 12 Times in 8 Posts


    Downloads
    0
    Uploads
    0
    Mentioned
    1 Post(s)
    Time Online
    9 h 24 m
    Avg. Time Online
    6 m
    Rep Power
    1
    Gamer IDs

    PSN ID: grotle_24
    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



    Join Date
    May 2016
    Gender
    Location
    Australia
    Posts
    199
    Userbars
    5
    Thanks
    380
    Thanked 189 Times in 84 Posts


    Downloads
    13
    Uploads
    0
    Mentioned
    17 Post(s)
    Time Online
    6 d 6 h 28 m
    Avg. Time Online
    5 m
    Rep Power
    5
    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 (1 Week Ago),Zachafer (1 Week Ago)

  5. #14
    linttastic's Avatar
    Join Date
    Apr 2020
    Gender
    Location
    California
    Age
    28
    Posts
    24
    Userbars
    0
    Thanks
    8
    Thanked 12 Times in 8 Posts


    Downloads
    0
    Uploads
    0
    Mentioned
    1 Post(s)
    Time Online
    9 h 24 m
    Avg. Time Online
    6 m
    Rep Power
    1
    Gamer IDs

    PSN ID: grotle_24
    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 (1 Week Ago)

  7. #15



    Join Date
    May 2016
    Gender
    Location
    Australia
    Posts
    199
    Userbars
    5
    Thanks
    380
    Thanked 189 Times in 84 Posts


    Downloads
    13
    Uploads
    0
    Mentioned
    17 Post(s)
    Time Online
    6 d 6 h 28 m
    Avg. Time Online
    5 m
    Rep Power
    5
    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
  •