Nairaland Forum

Welcome, Guest: Join Nairaland / Login / Trending / Recent / New
Stats: 1262841 members, 1711962 topics. Date: Friday, 31 October 2014 at 09:43 PM

Python Programming - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / Python Programming (20388 Views)

What Can Python Programming Language Build? / Help! I Want To Learn Python Programming / Python Programming! Pls Help! (1) (2) (3) (4)

(0) (1) (2) (3) (4) (5) (6) (7) (8) (9) (Reply) (Go Down)

Re: Python Programming by Seun(m): 11:13pm On Dec 06, 2008
You wrote:
      averagelength=round(float(sum([len(word) for word in sentence.split()]))/ len(words))

That's not Python.  That's Perl in Python.  Real Python is both clear and concise. wink

PS: I don't think it works.
Re: Python Programming by jacob05(m): 11:31pm On Dec 06, 2008
Have tried it and it doesn't work

Cos if it doesn't work i wouldn't post it,
Re: Python Programming by Seun(m): 11:51pm On Dec 06, 2008
Ok, I'll try it as soon as I can.
Re: Python Programming by jacob05(m): 11:53pm On Dec 06, 2008
I will be glad if you can
Re: Python Programming by jacob05(m): 12:04am On Dec 07, 2008
But bro seun
what about you post
This is java in python

[B]NOW[/B]

THIS IS PERL IN PYTHON


you are getting me confused Will still  cool
Re: Python Programming by jacob05(m): 12:33am On Dec 07, 2008
Edited
def AverageWord (sentence):
averagelength=round(float(sum([len(word) for word in sentence.split()]))/ len(sentence.split()))

but bro Seun you started this shortcut codes
Re: Python Programming by Seun(m): 7:30pm On Dec 07, 2008
Java is wordy.  Perl is difficult to understand. Python is expressive and straightforward.
Re: Python Programming by jacob05(m): 10:12pm On Dec 07, 2008
COMING SOON

THIS IS NOT PYTHON tongue, THIS [COLOR=RED]IS C/C++ [/COLOR]IN PYTHON grin
Re: Python Programming by Seun(m): 10:15pm On Dec 07, 2008
I was just trying to help you man.
Re: Python Programming by jacob05(m): 10:21pm On Dec 07, 2008
start by teaching me how to configure my mod_python 3.3.1(pls)
Re: Python Programming by jacob05(m): 12:36am On Dec 31, 2008
Python 2.6.2 released with python 3
Re: Python Programming by webdezzi(m): 8:47pm On Dec 31, 2008
whats going on here, are you guys still speaking i english language

or is it english in python grin

@jacob05
what do you mean by "Python 2.6.2 released with python 3 "
Re: Python Programming by jacob05(m): 7:10am On Jan 02, 2009
@webdezzi
Go to python.org and see for ur self.{professor ladigun}
Re: Python Programming by webdezzi(m): 2:18pm On Jan 02, 2009
i am asking how python versions relates to your last discussion
Re: Python Programming by EDIPO(m): 3:21pm On Jan 05, 2009
hi jacob, compliments ofthe season.
i need the code for games.py
i was referred to it in a text i was reading and i have not been able to go beyond that point since.
seun, if you can help, i would be glad.
thanks.
Re: Python Programming by Seun(m): 1:07am On Jan 06, 2009
There's nothing like games.py. Get a better text.
Re: Python Programming by mariamambaby: 11:20pm On Jan 07, 2009
Hello, ,
My name is Miss Mariama Majzoub al-Khalifa. i am a beautiful and romantic young girl i was impressed when i saw your profile in www.nairaland.com and will like to establish a long lasting relationship with you. In addition,i will like you to reply me. (mariama_24@hotlemail.com) This is because i don't know the possibilities of remaining in forum for a long time. please If you are interested in knowing more about me, and for me to send you some pictures of mine,
Thanks waiting to hear from you .
With all my love,
Miss Mariama Majzoub al-Khalifa.

mariama_24@hotlemail.com
Re: Python Programming by jacob05(m): 9:02am On Jan 08, 2009
@E_EIPO
compliments to you too,and about the game.py stuff which text or book are you reading cus there must be a link or url for your game.py code if true.
@mariamambaby
are you taking to me grin,or him lipsrsealed,no no they or maybe them embarassed, who are you referring to
@seun
so long since have had from you.compliments of the season.
Re: Python Programming by jacob05(m): 9:03am On Jan 08, 2009
@E_EIPO
compliments to you too,and about the game.py stuff which text or book are you reading cus there must be a link or url for your game.py code if true.
@mariamambaby
are you taking to me grin,or him lipsrsealed,no no they or maybe them embarassed, who are you referring to
@seun
so long since have had from you.compliments of the season.
Re: Python Programming by jacob05(m): 1:02am On Feb 09, 2009
hmmmmmmm, Python embarassed cry
Re: Python Programming by alexis(m): 4:14pm On Feb 09, 2009
Hi Guys,

Sorry - I have been missing in action for a while now. What's popping?
Re: Python Programming by webdezzi(m): 5:07pm On Feb 09, 2009
mariamambaby, sorry u posted right after the admin.

alexis:

Hi Guys,

Sorry - I have been missing in action for a while now. What's popping?

python.


Hello all,
Please i will like to know how you wud save vital info like, connection settings to database
say ur software was hacked, you dont want them to get ur connection settings.

here is what i do and i feel it's not secure
I save the login detail to the windows directory with an awkward name like "win32xl.dll" you wont want to mess with that . i save it deep deep inside a folder that you rarely navigate to, but always exists on most versions of windows.

but the hacl<er will still be able to locate it if my python program were to be decompiled-just a matter of seeing the path.
or let me know how you wud go around this.
Re: Python Programming by dhtml18(m): 11:21pm On Feb 09, 2009
Fine, i have never opened the code before, but i did lots of perl programming and also c too, i am going to start learning python, where do i get materials?
Re: Python Programming by jacob05(m): 10:15am On Feb 10, 2009
@dhtml
Good, python is the sweetest and neatest language you would ever code .trust me.
You can download it @ www.python.org.
Re: Python Programming by EDIPO(m): 1:09pm On Feb 10, 2009
hey people.

jacob05, seun, alexis how are you all guys doing?

thanks for your every note posted here. i am getting better with python.

i got the following problems, trust me, i have attempted some and i dont just understand some. i would appreciate if you can help me solutions.

i read all this stuff on my own, please do your bit in my career. here are the problems:

Challenges
1. Create a program that prints a list of words in random order. The program should print all the words and not repeat any.
2. Write a Character Creator program for a role-playing game. The player should be given a pool of 30 points to spend on four attributes: Strength, Health, Wisdom, and Dexterity. The player should be able to spend points from the pool on any attribute and should also be able to take points from an attribute and put them back into the pool.
3. Write a Who's Your Daddy? program that lets the user enter the name of a male and produces the name of his father. (You can use celebrities, fictional characters, or even historical figures for fun.) Allow the user to add, replace, and delete son-father pairs. The program should also allow the user to get a list of all sons, or fathers, or son-father pairs.
4. Improve the Who's Your Daddy program by adding a choice that lets the user enter a name and get back a grandfather. Your program should still only use one dictionary of son-father pairs. Make sure to include several generations in your dictionary so that a match can be found.
5. Create a game where the computer picks a random word and the player has to guess that word. The computer tells the player how many letters are in the word. Then the player gets five chances to ask if a letter is in the word. The computer can only respond with "yes" or "no". Then, the player must guess the word.

i currently use Python Programming for the Absolute Beginner by Michael Dawson. i have the e-copy, but there are some part of it that would require i have a CD that came with the book, if you have the cd or a copy of it, i would like to share with you please.

hope to read from you guys,thanks.
Re: Python Programming by jacob05(m): 4:03pm On Feb 10, 2009
@E_DIPO
you are welcomed

@QUESTION
Can't wait to get on my pc. grin
Re: Python Programming by EDIPO(m): 3:29pm On Feb 11, 2009
hey jac'

i tried working on the stuff again and came up with a solution for one of the questions. i left some comments in the code for you to examine as a part of it did not run as i have expected.

i have tried to attach it with this reply but i can't get it through cos of the .py extension, hope to hear from you soon. i would appreciate if i can get your mobile number, i can always send you a message if i have dropped any question for you. i hope it is ok with you.

here is the code:

#Write a Who's Your Daddy? program that lets the user enter the name of a male and
#produces the name of his father. (You can use celebrities, fictional characters,
#or even historical figures for fun.) Allow the user to add, replace,
#and delete son-father pairs. The program should also allow the user to get a list
#of all sons, or fathers, or son-father pairs.
#dipo elegbede, 10-02-09, 2155hrs



WIYF = {'dipo':'elegbede','wale':'adeyemo','owolabi':'awodein','bimbo':'salami',
'taribo':'west','austin':'okocha','titi':'onafeko'}

choice = None
while choice != '0':
print\
'''\t\tMENU
ENTER 0 ----- TO EXIT
ENTER 1 ----- TO ADD A FATHER:SON PAIR
ENTER 2 ----- TO REPLACE A PAIR
ENTER 3 ----- TO DELETE A PAIR
ENTER 4 ----- TO GET YOUR FATHER'S NAME
ENTER 5 ----- TO GET A LIST OF ALL FATHER:SON PAIRS
ENTER 6 ----- TO GET AL NAMES OF SONS ONLY
ENTER 7 ----- TO GET ALL SURNAMES ONLY
'''
choice = raw_input('What do you want to do?: ')
if choice == '0':
print'Good Bye!'

elif choice == '1':
own_name = raw_input('What\'s your name?: ')
if own_name in WIYF:
print'the name already exists,is',WIYF[(own_name).lower()],'isn\'tyour father?'
own_name = raw_input('What\'s your name?: ')
else:
print'Noted!'
dad_name = raw_input('What\'s your father\'s name?: ')
WIYF[(own_name).lower()] = dad_name
print'Your data has been added successfully!'

elif choice == '2':
replace_name = raw_input('Which name do you wish to replace?: ')
if replace_name in WIYF:
new_dad_name = raw_input('What\'s the new father\'s name?: ')
WIYF[(replace_name).lower()] = new_dad_name
print'Updated!'
else:
'No such name in here!'

elif choice == '3':
remove_name = raw_input('Which name do you want to delete?: ')
if remove_name in WIYF:
del WIYF[(remove_name).lower()]
print'\nIt has been removed'
else:
print'\nSuch name does not exist here!'

elif choice == '4':
who_are_you = raw_input('What is your name?: ')
if (who_are_you).lower() in WIYF:
print (who_are_you).upper(),'you\'re a son of',(WIYF[who_are_you.lower()]).upper()

elif choice == '5':
print'NAME\tSURNAME'
for name in WIYF:
print name.upper(),'\t',(WIYF[name.lower()]).upper()

elif choice == '6':
for name in WIYF:
print name

elif chioce == '7':
for name in WIYF:
print WIYF[name.lower()]

raw_input('Press the enter key to exit.')

#i still have problems with when choice == '2' and the name entered is not in WIYF
# the else part does not run, what could be responsible for that?

thanks

@ Seun

i am still waiting for your response Sir.
thanks
Re: Python Programming by jacob05(m): 6:18pm On Feb 11, 2009
@E_DIPO
Sorry for not been able to reply to your questions.i was and now not able to code cus of PHCN power issues in my area . I'm Currently in need of a laptop cus these PHCN issues are getting my mad. angry
Re: Python Programming by EDIPO(m): 6:30pm On Feb 11, 2009
@ jacobs05

no probs. i would wait for you to come p with the solutions. i am also working on to see if i can come up with something correct.

thanks
Re: Python Programming by jacob05(m): 11:30pm On Feb 11, 2009
TRY THESE
import time
WIYF = {'jacob':'oyebanji','dipo':'elegbede','wale':'adeyemo','owolabi':'awodein','bimbo':'salami',
        'taribo':'west','austin':'okocha','titi':'onafeko'}

def Add_Son_And_Father(son_name,father_name):
    if son_name in WIYF.keys() and father_name in WIYF.values():
        print"The name "+son_name.upper()+" and father "+father_name.upper()+" Already Exist"
        time.sleep(3)
    else:
        WIYF[(son_name).lower()] =father_name
        print'Your data has been added successfully!'
        time.sleep(3)
           
if __name__ == '__main__':
    while True:
        print\
           '''\t\tMENU
            ENTER 0 ----- TO EXIT
            ENTER 1 ----- TO ADD A SON:FATHER PAIR
            ENTER 2 ----- TO REPLACE A PAIR 
            ENTER 3 ----- TO DELETE A PAIR
            ENTER 4 ----- TO GET YOUR FATHER'S NAME
            ENTER 5 ----- TO GET A LIST OF ALL FATHER:SON PAIRS
            ENTER 6 ----- TO GET AL NAMES OF SONS ONLY
            ENTER 7 ----- TO GET ALL SURNAMES ONLY
           '''
        choice = raw_input('What do you want to do?: ')
        if choice=='0':
            break
        elif choice == '1':
            own_name = raw_input('What\'s your name?: ').lower()
            dad_name = raw_input('What\'s your father\'s name?: ').lower()
            Add_Son_And_Father(own_name,dad_name)
        elif choice =='2':
            replace_name = raw_input('Which name do you wish to replace?: ').lower()
            if replace_name in WIYF.keys():
                new_dad_name = raw_input('What\'s the new father\'s name?: ')
                WIYF[replace_name] = new_dad_name
                print'Updated!'
                time.sleep(3)
            else:
                print "The name specified do not Exit! "
                time.sleep(3)
        elif choice == '3':
            remove_name = raw_input('Which name do you want to delete?: ').lower()
            if remove_name in WIYF.keys():
                WIYF.pop(remove_name)
                print remove_name +" REMOVED! "
                time.sleep(3)
            else:
                print remove_name," DOES NOT EXIST! "
                time.sleep(3)
        elif choice == '4':
            who_are_you = raw_input('What is your name?: ').lower()
            if who_are_you in WIYF.keys():
                print who_are_you.upper(),'you\'re a son of',WIYF[who_are_you.lower()].upper()
                time.sleep(3)
            else:
                print "Your Father not in List! "
                time.sleep(3)
        elif choice == '5':
            print ";\n".join(["%s Son of %s" % (son.upper(),father.upper()) for son ,father in WIYF.items()])
            time.sleep(3)
        elif choice == '6':
            for i in WIYF.keys():
                print i.upper()
            time.sleep(3)
        elif choice =='7':
            for i in WIYF.values():
                print i.upper()
            time.sleep(3)
        else:
            print "INVALID CHOICE"
            time.sleep(3)
    print "BYE"
    time.sleep(3)
Re: Python Programming by jacob05(m): 2:52am On Feb 12, 2009
UpDated :
NEW features:
****Ablity to Save ALL DATA
****Abilty to Load DATA
****All OOP (I Think) undecided


import time
WIYF = {'jacob':'oyebanji','dipo':'elegbede','wale':'adeyemo','owolabi':'awodein','bimbo':'salami',
'taribo':'west','austin':'okocha','titi':'onafeko'}

def Add_Son_And_Father(son_name,father_name):
if son_name in WIYF.keys() and father_name in WIYF.values():
print"The name "+son_name.upper()+" and father "+father_name.upper()+" Already Exist"
time.sleep(3)
else:
WIYF[(son_name).lower()] =father_name
print'Your data has been added successfully!'
time.sleep(3)
def Replace_Name(replace_name):
if replace_name in WIYF.keys():
new_dad_name = raw_input('What\'s the new father\'s name?: ')
WIYF[replace_name] = new_dad_name
print'Updated!'
time.sleep(3)
else:
print "The name specified do not Exit! "
time.sleep(3)
def Delete_Pair(remove_name):
if remove_name in WIYF.keys():
WIYF.pop(remove_name)
print remove_name +" REMOVED! "
time.sleep(3)
else:
print remove_name," DOES NOT EXIST! "
time.sleep(3)
def Get_Father_Name(who_are_you):
if who_are_you in WIYF.keys():
print who_are_you.upper(),'you\'re a son of',WIYF[who_are_you.lower()].upper()
time.sleep(3)
else:
print "Your Father not in List! "
time.sleep(3)
def Load_File(filename):
try:
in_file = open(filename, "r"wink
while True:
in_line = in_file.readline()
if not in_line:
break
in_line = in_line[:-1]
son, father = in_line.split(","wink
WIYF[son] = father
in_file.close()
print "File Loaded Successfully !!!"
time.sleep(2)
except IOError:
print 'Unable to Load File'
time.sleep(2)
def Save_List(data,filename):
try:
out_file = open(filename, "w"wink
for x in data.keys():
out_file.write(x + "," + data[x] + "\n"wink
out_file.close()
print "File Saved Successfully !!!"
time.sleep(3)
except IOError:
print 'Unable to Save File'
time.sleep(2)
if __name__ == '__main__':
Try_Load_File()
while True:
print\
'''\t\tMENU
ENTER 0 ----- TO EXIT
ENTER 1 ----- TO ADD A SON:FATHER PAIR
ENTER 2 ----- TO REPLACE A PAIR
ENTER 3 ----- TO DELETE A PAIR
ENTER 4 ----- TO GET YOUR FATHER'S NAME
ENTER 5 ----- TO GET A LIST OF ALL FATHER:SON PAIRS
ENTER 6 ----- TO GET AL NAMES OF SONS ONLY
ENTER 7 ----- TO GET ALL SURNAMES ONLY
ENTER 8 ----- TO SAVE ALL SON:FATHERS NAMES
ENTER 9 ----- TO LOAD SON:FATHERS NAMES
'''
choice = raw_input('What do you want to do?: ')
if choice=='0':
break
elif choice == '1':
own_name = raw_input('What\'s your name?: ').lower()
dad_name = raw_input('What\'s your father\'s name?: ').lower()
Add_Son_And_Father(own_name,dad_name)
elif choice =='2':
replace_name = raw_input('Which name do you wish to replace?: ').lower()
Replace_Name(replace_name)
elif choice == '3':
remove_name = raw_input('Which name do you want to delete?: ').lower()
Delete_Pair(remove_name)
elif choice == '4':
who_are_you = raw_input('What is your name?: ').lower()
Get_Father_Name(who_are_you)
elif choice == '5':
print ";\n".join(["%s Son of %s" % (son.upper(),father.upper()) for son ,father in WIYF.items()])
time.sleep(3)
elif choice == '6':
for i in WIYF.keys():
print i.upper()
time.sleep(3)
elif choice =='7':
for i in WIYF.values():
print i.upper()
time.sleep(3)
elif choice =='8':
filename=raw_input("Filename To Save: "wink
Save_List(WIYF,filename)
elif choice =='9':
filename=raw_input("Filename To Load: "wink
Load_File(filename)
else:
print "INVALID CHOICE"
print "BYE"
time.sleep(3)


Waiting to Ear From you All Tomorrow,
MAKE I GO SLEEP OOOOOOOO.
Re: Python Programming by jacob05(m): 3:37pm On Feb 12, 2009
Hello world

(0) (1) (2) (3) (4) (5) (6) (7) (8) (9) (Reply)

Solution Of Linear Programming Problems Using Simplex Method / Project Topics Tips For Computer Science Undergraduates / Web Application Development Contest: Jajad Wins

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (0) (1) (2) (3) (4) (5) (6) (7) (8) (9)

Nairaland - Copyright © 2005 - 2014 Oluwaseun Osewa. All rights reserved. See Nairalist and How To Advertise. 114
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.