![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
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? |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
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)
__________________
Waterloo's Canadian Computing Competition (CCC) - Stage 2 Problems, Solutions, and Test Data Last edited by Sane; Nov 16th, 2005 at 6:50 PM. |
|
|
|
|
|
#3 | |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 642
Rep Power: 4
![]() |
Quote:
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! |
|
|
|
|
|
|
#4 |
|
Hobbyist Programmer
|
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? |
|
|
|
|
|
#5 | |
|
Hobbyist Programmer
Join Date: Aug 2005
Location: Hiding from... them...
Posts: 110
Rep Power: 4
![]() |
Quote:
__________________
:wq |
|
|
|
|
|
|
#6 |
|
Hobbyist Programmer
|
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? |
|
|
|
|
|
#7 |
|
Expert Programmer
|
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.
|
|
|
|
|
|
#8 |
|
Expert Programmer
|
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.
|
|
|
|
|
|
#9 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Sane, that code is nasty. :p
Good work mate. I only have one complaint: after print, put a space in: print "Next >>" |
|
|
|
|
|
#10 |
|
Programming Guru
![]() |
What do you mean by nasty? o_o
And as ColdDeath said, the next step would be conditions, loops and functions. *thumbs up* |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|