Caculate age

Ben Patel benvpatel at yahoo.com
Sun Feb 2 16:57:52 EST 2003


Thanks for your quick response. 
I am trying to write a function which will take a String as an argument and add it to a hashtable. If the value entered is in the Hashtable then print it or else error out. 
Here is what I have written so far : 
import sys 
def mydict(y):
#y = raw_input ("Please enter a String: ")
    if len(y) > 1:
        x={}
        #x={i:y}
        x[i] = i
        x[i] = y
        i = i+1
        #return x.values()
#print x.has_key(1)
#y=x.keys()
#z=x.values()
#print y, z
print x.keys()
print x.values()

Any advice ! 
-Thanks

 Laura Creighton <lac at strakt.com> wrote:> Hi:
> 
> I am new at Python. I have an assignment to be written by tomorrow in Python.
> - Calculate a person's age based on a brithdate in any format
> 
> Any help will be appreciated.
> 
> Thanks in advance
> 
> Ben
> -- 
> http://mail.python.org/mailman/listinfo/python-list

I assume that you have a program that works to calculate a person's
age based on _some_ format. If you cannot do that, then you need to
learn Python, period, and while learning Python is fast, I don't
know if it is that fast. http://www.hetland.org/python/instant-python.php
is probably your best bet at trying to learn Python overnight, unless
you are already an experienced programmer where 'Dive into Python'
at http://diveintopython.org/ might suit you better. One day is
still probably asking a lot.

But assuming that you have a program that works for some valid date,
the hard thing about this assignment is the 'any format' part. This
sort of thing is best done with unit tests, and as part of the
http://diveintopython.org/ reference you get 
'http://diveintopython.org/roman_divein.html' which explains how you
do this, with examples for converting numbers from 1-3999 into their
Roman Numeral equivalents. While this is the right way to do things,
it is quite possible that it has nothing to do with how your teacher
desires you to solve your assignment, which means you could be
100% correct and still get a rotten mark, which would stink.

Good luck,
Laura Creighton


---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20030202/591bbf16/attachment.html>


More information about the Python-list mailing list