Python Forum
home work rolling average
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
home work rolling average
#2
(Mar-02-2019, 02:32 AM)arcticfox286 Wrote: by looping though it and having it read each number then incriment by one adding each number then dividing by the count.. but for the life if me i can't under stand how to code it

That pretty much explains how to code it. Loop through the file. Convert each line to an integer. Add that integer to the total, and add one to the count. Divide the total by the count to get the average. Print the integer and the current average.

I'm not sure why they want two functions. Is there more explanation as to why? Maybe they want an average function. In that case, start with an empty list, and as each line is converted to an integer, append it to the list. Then send the list to the average function. That's incredibly inefficient, but I can't think what else they mean by using two functions.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
home work rolling average - by arcticfox286 - Mar-02-2019, 02:32 AM
RE: home work rolling average - by ichabod801 - Mar-02-2019, 04:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Could someone please help walk me through my home work tetoronga 3 3,014 Mar-22-2018, 09:33 PM
Last Post: nilamo
  a Home language TDH 4 3,472 Oct-17-2017, 03:30 PM
Last Post: buran
  problem nin home work maayan11 1 2,844 Apr-27-2017, 04:01 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020