Need help on a program.

Captain Obvious captainTRASHobvious at rocketTRASHmail.com
Wed Oct 18 19:30:41 EDT 2000


Fixed it...I was using the wrong kind of loop.  Thanks to all of you who sent emails...turned out I just needed to spend some time
with it and figure it out myself.

Jim


--
===

Thanks for taking the time to read my posting.

Take out the TRASH to respond via email.

Any views expressed in this USENET posting and/or
attachments are not necessarily those of
Wartburg College.

Go Knights!


"Captain Obvious" <captainTRASHobvious at rocketTRASHmail.com> wrote in message news:8sl2f7$fua$1 at ns2.bcs.moore.com...
> I am taking a Python class in college, and am stuck on a program I am writing.
>
> Here is the error I get:
> Traceback (innermost last):
>   File "<string>", line 1, in ?
>   File "C:\Jim's Stuff\College Stuff\CS120\Python Programs\JRC_07.py", line 37, in ?
>     main()
>   File "C:\Jim's Stuff\College Stuff\CS120\Python Programs\JRC_07.py", line 17, in main
>     infile = open("p7.dat", "r")
> IOError: [Errno 2] No such file or directory: 'p7.dat'
>
> Here is the program I wrote:
>
> # JRC_07.py
> # Program written by James Cory for October 18, 2000
> # This program, using p7.dat, will keep a running total of heating degree days
> # and cooling degree days.  One heating degree day is added for every degree the
> # temperature is over 80 degrees Fahrenheit, and one cooling degree day is added
> # for every degree the temperature is below 60 degrees Fahrenheit.
>
> def main():
>     #Greeting Section
>     print "This program, using p7.dat, will keep a running total of heating degree days"
>     print "and cooling degree days.  One heating degree day is added for every degree the"
>     print "temperature is over 80 degrees Fahrenheit, and one cooling degree day is added"
>     print "for every degree the temperature is below 60 degrees Fahrenheit."
>     hdd = 0
>     cdd = 0
>     day = 0
>     infile = open("p7.dat", "r")
>     temp = eval(infile.readline())
>     while temp != "":
>         if temp > 80:
>             amount = temp-80
>             hdd=hdd+amount
>             day=day+1
>             print "Day: ", day, "Cooling Degree Days: ", cdd, "Heating Degree Days: ", hdd
>         elif temp < 60:
>             amount = 60-temp
>             cdd=cdd+amount
>             day=day+1
>             print "Day: ", day, "Cooling Degree Days: ", cdd, "Heating Degree Days: ", hdd
>         else:
>             day=day+1
>             print "Day: ", day, "Cooling Degree Days: ", cdd, "Heating Degree Days: ", hdd
>     infile.close
>     print
>     print "+---------------------------------------------------------------------------+"
>     print "The final results are:" cdd, "Cooling Degree Days: ", hdd, "Heating Degree Days."
> main()
> raw_input ("Press <enter> to quit")
>
> Thanks in advance.  I can't get ahold of my professor, and am really stuck.
>
>
> --
> ===
>
> Thanks for taking the time to read my posting.
>
> Take out the TRASH to respond via email.
>
> Any views expressed in this USENET posting and/or
> attachments are not necessarily those of
> Wartburg College.
>
> Go Knights!
>
>
>




More information about the Python-list mailing list