Python Programming

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 21, 2009, 10:09 PM
430598 members and 297746 Topics
Latest Member: tejuu
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  Python Programming
Pages: (1) (2) (3) (4) (5) (6) (7) Go Down Send this topic Notify of replies
Author Topic: Python Programming  (Read 5759 views)
Seun (m)
Re: Python Programming
« #64 on: December 06, 2008, 11:13 PM »

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.
jacob05 (m)
Re: Python Programming
« #65 on: December 06, 2008, 11:31 PM »

Have tried it and it doesn't work???

Cos if it doesn't work i wouldn't post it,
Seun (m)
Re: Python Programming
« #66 on: December 06, 2008, 11:51 PM »

Ok, I'll try it as soon as I can.
jacob05 (m)
Re: Python Programming
« #67 on: December 06, 2008, 11:53 PM »

I will be glad if you can
jacob05 (m)
Re: Python Programming
« #68 on: December 07, 2008, 12:04 AM »

But bro seun
what about you post
This is java in python

NOW

THIS IS PERL IN PYTHON


you are getting me confused Huh Will still  Cool
jacob05 (m)
Re: Python Programming
« #69 on: December 07, 2008, 12:33 AM »

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
Seun (m)
Re: Python Programming
« #70 on: December 07, 2008, 07:30 PM »

Java is wordy.  Perl is difficult to understand. Python is expressive and straightforward.
jacob05 (m)
Re: Python Programming
« #71 on: December 07, 2008, 10:12 PM »

COMING SOON

THIS IS NOT PYTHON Tongue, THIS IS C/C++ IN PYTHON Grin
Seun (m)
Re: Python Programming
« #72 on: December 07, 2008, 10:15 PM »

I was just trying to help you man.
jacob05 (m)
Re: Python Programming
« #73 on: December 07, 2008, 10:21 PM »

start by teaching me how to configure my mod_python 3.3.1(pls)
jacob05 (m)
Re: Python Programming
« #74 on: December 31, 2008, 12:36 AM »

Python 2.6.2 released with python 3
webdezzi (m)
Re: Python Programming
« #75 on: December 31, 2008, 08:47 PM »

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 "
jacob05 (m)
Re: Python Programming
« #76 on: January 02, 2009, 07:10 AM »

@webdezzi
Go to python.org and see for your self.{professor ladigun}
webdezzi (m)
Re: Python Programming
« #77 on: January 02, 2009, 02:18 PM »

i am asking how python versions relates to your last discussion
E_DIPO (m)
Re: Python Programming
« #78 on: January 05, 2009, 03:21 PM »

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.
Seun (m)
Re: Python Programming
« #79 on: January 06, 2009, 01:07 AM »

There's nothing like games.py.  Get a better text.
mariamambaby
mariama_24@hotlemail.com
« #80 on: January 07, 2009, 11:20 PM »


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
jacob05 (m)
Re: Python Programming
« #81 on: January 08, 2009, 09:02 AM »

@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 Lips sealed,no no they Huh or maybe them Embarrassed, who are you referring to Huh
@seun
so long since have had from you.compliments of the season.
jacob05 (m)
Re: Python Programming
« #82 on: January 08, 2009, 09:03 AM »

@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 Lips sealed,no no they Huh or maybe them Embarrassed, who are you referring to Huh
@seun
so long since have had from you.compliments of the season.
jacob05 (m)
Re: Python Programming
« #83 on: February 09, 2009, 01:02 AM »

hmmmmmmm, Python  Embarrassed  Cry
alexis (m)
Re: Python Programming
« #84 on: February 09, 2009, 04:14 PM »

Hi Guys,

Sorry - I have been missing in action for a while now. What's popping?
webdezzi (m)
Re: Python Programming
« #85 on: February 09, 2009, 05:07 PM »

mariamambaby, sorry u posted right after the admin.

Quote from: alexis on February 09, 2009, 04:14 PM
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 your software was hacked, you dont want them to get your 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.

*dhtml
Re: Python Programming
« #86 on: February 09, 2009, 11:21 PM »

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?
jacob05 (m)
Re: Python Programming
« #87 on: February 10, 2009, 10:15 AM »

@dhtml
Good, python is the sweetest and neatest language you would ever code .trust me.
You can download it @ www.python.org
E_DIPO (m)
Re: Python Programming
« #88 on: February 10, 2009, 01:09 PM »

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.
jacob05 (m)
Re: Python Programming
« #89 on: February 10, 2009, 04:03 PM »

@E_DIPO
you are welcomed

@QUESTION
Can't wait to get on my pc. Grin
E_DIPO (m)
Re: Python Programming
« #90 on: February 11, 2009, 03:29 PM »

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
jacob05 (m)
Re: Python Programming
« #91 on: February 11, 2009, 06:18 PM »

@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
E_DIPO (m)
Re: Python Programming
« #92 on: February 11, 2009, 06:30 PM »

@ 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
jacob05 (m)
Re: Python Programming
« #93 on: February 11, 2009, 11:30 PM »

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)
jacob05 (m)
Re: Python Programming
« #94 on: February 12, 2009, 02:52 AM »

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")
        while True:
            in_line = in_file.readline()
            if not in_line:
                break
            in_line = in_line[:-1]
            son, father = in_line.split(",")
            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")
        for x in data.keys():
            out_file.write(x + "," + data
  • + "\n")
            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: ")
                Save_List(WIYF,filename)
            elif choice =='9':
                filename=raw_input("Filename To Load: ")
                Load_File(filename)
            else:
                print "INVALID CHOICE"
        print "BYE"
        time.sleep(3)


    Waiting to Ear From you All Tomorrow,
    MAKE I GO SLEEP OOOOOOOO.
  • jacob05 (m)
    Re: Python Programming
    « #95 on: February 12, 2009, 03:37 PM »

    Hello world Huh
     I Have A Problem With Raise Event In C#  Ms .net Core - Mcad-mcsd, E-books In .chm Format  Mcts 70-536 Brain Dumps  Page 2
    Pages: (1) (2) (3) (4) (5) (6) (7) Go Up Send Topic to Friend by E-mail Reply 


    Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
    Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

    Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

    Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
    Nairaland Forum | Powered by SMF 1.0.12.
    © 2001-2005, Lewis Media. All Rights Reserved.