Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 16th, 2005, 6:11 PM   #1
Nebula
Hobbyist Programmer
 
Nebula's Avatar
 
Join Date: Oct 2005
Posts: 193
Rep Power: 3 Nebula is on a distinguished road
Send a message via AIM to Nebula
Python Info prog.

This is my first simi-large program that i did recently and I thought I"d post it to show off. ^_^ Its nothing great but i will be adding things to it as time goes on,
eventually an e-mail option and such.

#*************************************
#  Welcome to the User Info. program
# This program was writtin by: Nebula
#programmingforums on on IRC @freenode
#*************************************


#Introduce the program to the user

print"Hello and welcome to the User Information program."
print"Designed to take your info and record it into an archive."
print"Please begin by answering the first question"
print""
print""
print""

#get info about user

name = raw_input("What is your name:")
print"Next >>"
age = input("What is your age:")
print"Next >>"
year = input("What year were you born:")
print"Next >>"
sign = raw_input("What is your sign:")
print"Next >>"
height = input("What is your height:")
print"Next >>"
shoe = input("What is your shoe size:")
print"Next >>"
home = raw_input("What is your home state:")
print"Next >>"
city = raw_input("What si your home city:")
print""
print""

#tell the user that they will be doing the computer part

print"Now we go on to the computer specs. section."
print""
proc = raw_input("What type of processor do you have:")
print""
print""
print""
print"Here is your info. if its wrong, too bad."
print"Your name is :", name
print""
print"Your age is:", age
print""
print"You were born in:", year
print""
print"Your sign is:", sign
print""
print"Your height is:", height
print""
print"Your shoe size is:", shoe
print""
print"Your home state is:", home
print""
print"Your home city is:", city
print""
print"Computer specs. section."
print""
print"Your processor type is:", proc
print"Congrats, your information is now beng stored in an archive within your computer."
print"Hope you enjoyed the program"

Have fun. Plz, i am open for ANY tips of advise.
__________________
When will Jesus bring the porkchops?
Nebula is offline   Reply With Quote
Old Nov 16th, 2005, 6:30 PM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,840
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
And what did you mean by semi-large program? =S


But when the code says it stored the data, it actually should, or am I misreading something?


Keep in mind your program is still very good. This is just my method of how I would do this, and I hope this can help you learn a bit more and motivate you to further your abilities.

print "Hello and welcome to the User Information program.\nDesigned to take your info and record it into an archive.\nPlease begin by answering the first question"
info = ["is your name","is your age","year were you born","is your sign","is your height","is your shoe size","is your home state","is your home city","type of processor do you have"]

def get_data(info, data = []):
    for item in info: data.append( raw_input("What %s: "%(item)) )
    return data

def give_data(data, info):
    i = 0
    for i in range(len(info)):
        print "What %s: %s"%( info[i], data[i] )
        i += 1

def save_data(data, fileName):
    file = open(fileName+".txt", "w")
    file.write( '\n'.join(data) )
    file.close()

def main(info):
    print ""
    data = get_data(info)
    print ""
    give_data(data, info)
    save_data(data, data[0])
    if raw_input("Again (Y/N)? ").upper() == "Y": main(info)

if __name__ == "__main__": main(info)

Last edited by Sane; Nov 16th, 2005 at 6:50 PM.
Sane is online now   Reply With Quote
Old Nov 16th, 2005, 6:45 PM   #3
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 642
Rep Power: 4 Jessehk is on a distinguished road
Quote:
Originally Posted by Sane
And how exactly is this a semi-large program? =S


When the code says it stored the data, it actually should.

I'll toss up my version in a couple secs:

Obviously he is at a level where this program was an accomplishmnet for him.
If he had to work hard and learn to make that program, then he deserves to feel proud of it.
You shouldn't discourage someone by proving how much better you are.
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS!
Jessehk is offline   Reply With Quote
Old Nov 16th, 2005, 8:51 PM   #4
Nebula
Hobbyist Programmer
 
Nebula's Avatar
 
Join Date: Oct 2005
Posts: 193
Rep Power: 3 Nebula is on a distinguished road
Send a message via AIM to Nebula
Thnx to both of you but this was just a proggy to take someones info, not store it. but to send the info in an e-mail to you. Like i said, i havnt done that yet.
__________________
When will Jesus bring the porkchops?
Nebula is offline   Reply With Quote
Old Nov 16th, 2005, 8:57 PM   #5
Silvanus
Hobbyist Programmer
 
Silvanus's Avatar
 
Join Date: Aug 2005
Location: Hiding from... them...
Posts: 110
Rep Power: 4 Silvanus is on a distinguished road
Quote:
Originally Posted by Nebula
Thnx to both of you but this was just a proggy to take someones info, not store it. but to send the info in an e-mail to you. Like i said, i havnt done that yet.
The confusion arose from the fact that the program as you wrote it tells the user it has stored his/her (I am SO PC) information.
__________________
:wq
Silvanus is offline   Reply With Quote
Old Nov 16th, 2005, 9:59 PM   #6
Nebula
Hobbyist Programmer
 
Nebula's Avatar
 
Join Date: Oct 2005
Posts: 193
Rep Power: 3 Nebula is on a distinguished road
Send a message via AIM to Nebula
i know, but it acts like a script (even though python is a scripting langauge) that when the program is done hr alst command is a command that will send the information given by the user via e-mail to me. or whoever i choose.
__________________
When will Jesus bring the porkchops?
Nebula is offline   Reply With Quote
Old Nov 16th, 2005, 10:04 PM   #7
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 707
Rep Power: 5 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
My first program in Python was to calculate a bunch of information like that. Dog years, cat years, all the differnt years I could find, then it would ask them if they thought I ws sexy, and if they answered no, the it told them that they sucked, and if it answered yes, then it said, damn right he is. I love interacting with people with programs.
thechristelegacy is offline   Reply With Quote
Old Nov 17th, 2005, 1:08 AM   #8
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 4 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
Nebula:
Cool Now don't stop trying to learn, if i was you now, i would try to learn some control statements/loops, such as: if/elif/else statement, for loop, while loop.

Then have a look at how to make and use a function (sometimes called a method) they python tutorial can help you here

Good Luck.
__________________
Join us at #programmingforums @ irc.freenode.net!

My software never has bugs. It just develops random features.
coldDeath is offline   Reply With Quote
Old Nov 17th, 2005, 11:25 AM   #9
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Sane, that code is nasty. :p

Good work mate. I only have one complaint: after print, put a space in:
print "Next >>"
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 17th, 2005, 3:29 PM   #10
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,840
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
What do you mean by nasty? o_o

And as ColdDeath said, the next step would be conditions, loops and functions. *thumbs up*
Sane is online now   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:13 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC