print ('Why hello there!')
print ('\n')
print ('It seems I have been given the ability to process more complex commands...')
print ('\n')
yourname1 = input('Would you mind telling me your name?')
print ('\n')
print ('\n')
print ('Thank you,', yourname1,',' 'who is that friend of yours?')
print ('\n')
print ('\n')
yourname2 = input('Yes you! Tell me your name please.')
print ('\n')
print ('\n')
print ("Wonderful, pleasure to meet you,", yourname1,','  "and you,", yourname2)
print ('\n')
print ('\n')
print ('Would you two humor me and give me your individual birth dates?')
print ('\n')
print ('\n')
print (yourname1)
snum = input('What is your date of birth (YYYYMMDD)?:')
birth1 = int(snum)
print ('\n')
print ('\n')
print (yourname2)
snum = input('What is your date of birth (YYYYMMDD)?:')
birth2 = int(snum)
print ('\n')
print ('\n')
print (birth1)
print ('\n')
print ('\n')
print (birth2)

After creating a "Mad Lib Generator" and several other trivial programs in Python 3.1, I have been asked to create my first "Smart Program" - one that makes decisions for itself...
As you may or may not have noticed, the code above is my first attempt at said "Smart Program"
(The final program being one which can analyze two 8-digit birth dates, return them in proper MM/DD/YYYY format, and tell which of the two individuals is older - Then be given each person's savings amount in USD, convert them to British pounds, and return with who is the richest of the two)
Clearly, I am in that stage of programming preparatory to even "the beginner".
I am a fetal python.

That said, I would greatly appreciate any assistance in hurtling over this "confusing" problem.

Recommended Answers

All 7 Replies

snum = input('What is your date of birth (YYYYMMDD)?:')
birth1 = int(snum)

Use raw_input...

The method input always return numeric value
The method raw_input always return string value

snum = raw_input('What is your date of birth (YYYYMMDD)?:')
dateOfBirt = snum[0:4] + '/' +snum[4:6] + '/' + snum[6:8]
#snum[startIndex:endIndex]
# if YYYYMMDD = 20100201 then dateOfBirt will be 2010/02/01

And then... to compare:

#if date is 2010/10/05

#date of user
Y1 = int(snum[0:4]) #year
M1 = int(snum[5:7]) #month
D1 = int(snum[8:10]) #day

#date of him friend
Y2 = int(snum[0:4]) #year
M2 = int(snum[5:7]) #month
D2 = int(snum[8:10]) #day

#if dates are without lines use snum[0:4], snum[4:6], snum[6:8]...

#comare the dates...

To convert currency:

usdInPounts = usd / 1.5666
# 1 pounds = 1.5666 dolars

I hope that helped...

Krstevski read this again.

Raw_input has been removed in python 3.x(input in python 3.x dos the same as raw_input in python 2.x)

Upss... I`m sorry, I did not know about it, I still use 2.6...
Thanks for the information snippsat. :)

Thank you both for your help!
Glad I joined this forum..

Oh wait! Actually, I would like to learn how to compare the values in python, (date1 vs. date2/ savings $1 vs. savings $2) I am not sure how to make the program decide which is larger of the two.. =(

print ('Why hello there!')
print ('\n')
print ('It seems I have been given the ability to process more complex commands...')
print ('\n')
yourname1 = input('Would you mind telling me your name?')
print ('\n')
print ('\n')
print ('Thank you,', yourname1,',' 'who is that friend of yours?')
print ('\n')
print ('\n')
yourname2 = input('Yes you! Tell me your name please.')
print ('\n')
print ('\n')
print ("Wonderful, pleasure to meet you,", yourname1,','  "and you,", yourname2)
print ('\n')
print ('\n')
print ('Would you two humor me and give me your individual birth dates?')
print ('\n')
print ('\n')
print (yourname1)
snum = input('What is your date of birth (YYYYMMDD)?:')
birth1 = snum[4:6] + '/' +snum[6:8] + '/' + snum[0:4]
y1 = int(snum[6:10]) #year
print ('\n')
print ('\n')
print (yourname2)
snum = input('What is your date of birth (YYYYMMDD)?:')
birth2 = snum[4:6] + '/' +snum[6:8] + '/' + snum[0:4]
y2 = int(snum[6:10]) #year
print ('\n')
print ('\n')
print (birth1,', am I correct,', yourname1,'?')
print ('\n')
print ('\n')
print (birth2,', am I correct,', yourname2,'?')
print ('\n')
print ('\n')
def compare(y1, y2):
    if y1 < y2:
        y1, "is older than", y2
    elif y1 > y2:
        y1, "is younger than", y2
    else:
        x, "and", y, "are the same age!"
compare(y1, y2)

this is what i did - however the program, though it doesn't crash, just ends prior to the comparison portion..

Never-mind I got it -> I forgot to write "print" + I had the wrong values for y1 and y2
yay!

After

print (birth1,', am I correct,', yourname1,'?')

the program should be able to get yourname1's answer and do something if the answer is no.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.