Thanks for the replies, Dave and Joel. The reason I&#39;m not just using the time or datetime modules for a random date is because it&#39;s restricted to 1970-2038; I&#39;m pulling dates from 1600-3099. Thanks a lot for the pointer about the leap years, Dave, as well the class instances; just updated it and it&#39;s all working now, and also included the rest of the code too w/ answer verification and time tracking. <br>
<br>I want to start using this program to test myself for speed calculation using Zeller&#39;s formula, it&#39;s pretty cool for determining the days of dates - <a href="http://mathforum.org/dr/math/faq/faq.calendar.html">http://mathforum.org/dr/math/faq/faq.calendar.html</a><br>
<br>Because of the way variables C and D are split up from the year in the formula, I split up the year for self.c and self.y.<br><br>------------------------<br><br>import random, time, datetime, calendar<br><br>class Date:<br>
    def __init__(self):<br>        self.c = random.randint(16,30) <br>        self.y = random.randint(0,99) <br>        self.month = random.randint(1,12)<br>        self.year = self.c*100 + self.y<br>        <br>        apr = [4,6,9,11]<br>
        feb = [2]<br>        notleap = [1700, 1800, 1900, 3000]<br>                    <br>        if self.month in feb:<br>            if self.year%4 == 0:<br>                if self.year in notleap:<br>                    self.k = random.randint(1,28)<br>
                else:<br>                    self.k = random.randint(1,29)<br>            else:<br>                self.k = random.randint(1,28)<br>        elif self.month in apr:<br>            self.k = random.randint(1,30)<br>
        else:<br>            self.k = random.randint(1,31)<br>    <br>        if self.month in [1,2]:<br>            d = self.y - 1<br>            m = self.month + 10<br>        else:<br>            d = self.y<br>            m = self.month - 2<br>
                <br>        z = self.k + (13*m-1)/5 + d + d/4 + self.c/4 - 2*self.c<br><br>        if z &lt; 0:<br>            r = (abs(z)/7)*7 + z + 7<br>        else: <br>            r = z%7<br>    <br>        dict = { 0: &#39;Sunday&#39;, 1: &#39;Monday&#39;, 2: &#39;Tuesday&#39;, 3: &#39;Wednesday&#39;, 4: &#39;Thursday&#39;, 5: &#39;Friday&#39;, 6: &#39;Saturday&#39; }<br>
        self.day = dict[r]<br>        <br>t1m = time.localtime().tm_min<br>t1s = time.localtime().tm_sec<br>t1 = t1m + t1s/100.0<br>n = 0<br>x = 0<br><br>while n &lt; 10:<br>    newdate = Date()        <br>        <br>    print &#39;\n&#39;,calendar.month_name[newdate.month], newdate.k,&#39;,&#39;, newdate.year,&#39;=&#39;, <br>
    answer = raw_input()        <br>    if answer.capitalize() == newdate.day:<br>        pass<br>    else:<br>        x += 1    <br>    n += 1<br>    <br>t2m = time.localtime().tm_min<br>t2s = time.localtime().tm_sec<br>
t2 = t2m + t2s/100.0<br>td = t2 - t1        <br>        <br>print &#39;\n&#39;,x,&#39;out of 10 wrong\nAvg time/question:&#39;,td/10,&#39;\nTotal time:&#39;,td<br><br><br><div class="gmail_quote">On Mon, Sep 27, 2010 at 10:21 PM, Dave Angel <span dir="ltr">&lt;<a href="mailto:davea@ieee.org">davea@ieee.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

  
    
  
  <div bgcolor="#ffffff" text="#000000">
    <br>
    <br>
    On 2:59 PM, Steven D&#39;Aprano wrote:
    <blockquote type="cite"><div class="im">
      <pre>On Tue, 28 Sep 2010 08:55:36 am Carter Danforth wrote:

</pre>
      <blockquote type="cite">
        <pre>class Date:
    c = random.randint(16,30)
    y = random.randint(0,99)
    month = random.randint(1,12)
</pre>
      </blockquote>
      </div><pre>Here&#39;s your problem: you are creating a class where all the attributes 
(called &quot;members&quot; in some other languages) belong to the class and are 
shared by all instances.

Python classes are themselves objects, and the code inside the class 
body gets executed *once*, when the class is created. So in this case, 
the Date class chooses a single random month, *once*, and all instances 
share this attribute Date.month.

To get the behaviour you are after, you need to use instance attributes, 
which means referring to self. The usual place to do this is in the 
__init__ method, which is called when the instance is being 
initialised:

class Date:
    def __init__(self):
        self.month = random.randint(1,12)
        # etc.



By the way, why do you calculate a century and year separately, then add 
c+y to get the year? It would be easier to just say:

year = random.randint(1600, 3099)



</pre>
    </blockquote>
    That&#39;s the big problem, although it&#39;s also worth pointing out that
    you&#39;ll need a new instance each time through the loop.  It&#39;s not
    enough to call Date(), you also have to bind it to a name, and use
    that name for attribute lookup.    So something like<br>
        mydate = Date()<br>
        year = mydate.y + ....<br>
    <br>
    But there are at least a few subtle problems left.  One is that many
    of the years are divisible by four but do not have 29 days in
    February.  For example, 1800, 1900, 2100 are not leap years.<br>
    <br>
    Next problem is that the dates are not evenly distributed over the
    entire range of years.  The 14th of February will be more likely to
    be chosen than the sixth of July.  You can decide that this is
    deliberate, but it is a consideration.<br>
    <br>
    Third, the program doesn&#39;t do anything to check the user&#39;s answer. 
    For that matter, there&#39;s no timing going on either.<br>
    <br>
    Depending on the learning goals of this project, I&#39;d consider using
    the datetime module, and method:<br>
    <br>
    <tt>mydate = date.</tt><tt>fromordinal</tt><big>(</big><i>ordinal</i><big>)<br>
      <br>
      Now you can make a single randint() call, once you precalculate
      the starting and ending dates desired.   And this module also
      gives you other things you need, such as the weekday() method.<br>
      <br>
      DaveA<br>
      <br>
    </big>
  </div>

</blockquote></div><br>