View Single Post
Old 2016-11-09, 05:59   #3
WraithX
 
WraithX's Avatar
 
Mar 2006

2·35 Posts
Default

Quote:
Originally Posted by kelzo View Post
I have a problem. I don't know how to get input from users and calculate in the way I need to. Here is my prompt for the code..

Here is a sample output.

This program computes the heating and cooling
degree-days for Harrisburg, PA, over a period
of time, using data from the Penn State
Climatologist website.

Start date (e.g., 1/1/2013)? 11/1/2013
End date (e.g., 12/31/2013)? 10/31/2014

Heating degree-days: 4510.13
Cooling degree-days: 13.64
First, like LaurV said, using "code" tags will preserve spacing in the code you paste here and will make it easily readable.

An example will look like this:
Code:
def main():
    print(getAverageTemps("2013-11-01", "2014-10-31"))

if __name__ == "__main__":
    main()
You can either put the "code" tags in manually ["CODE"][/"CODE"] (without the double-quotes), or click on the "#" symbol in the option bar while composing your post. Then, paste your code in-between the tags and it will show up formatted nicely.

Second, are you learning this material in a class? Have you covered user input yet? Are you allowed to use Google to find what functions are available?
If you Google for "python user input", the first result (for me) points to a tutorial on how to get user input, and then what to do with that input depending on if it is a string or an integer, etc. You can see that here: http://anh.cs.luc.edu/python/hands-o...onHtml/io.html

Third, is the code you posted your own code, or sample code that was provided to you? In either event, add the "get date from user" lines of code to your "main" function, and try to convert the dates as requested. Do you know how to do this yet, or where to start looking to do this? If not, here's a hint: slice <- mouse-over to see

Show us what your new code looks like and let us know of any problems or errors you run into.
WraithX is offline   Reply With Quote