#16
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Bombay, India
    Posts
    159
    Rep Power
    12
    Something like this, is it?

    Code:
    >>> gradeList=['Dexter',100,'Excellent!','DeeDee',50,'Satisfactory!','Bubbles',20,'Poor!']
    so convert it into a list of lists!

    Subha
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Bombay, India
    Posts
    159
    Rep Power
    12
    did u get that Jack?

    Subha
  4. #18
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    arg i feel so stupid.. what am i suppose to do with that?
  6. #19
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    This should clear things up... hopefully...

    There are three different programs that you have to write. They each accomplish different aspects of the grade management:

    * View all grades: If the user types the correct administrator's password, the program should display a list of all of the students in the system along with their grades and comments.
    * View a student's grade: Used to view the grades for a single student. If the given userid isn't in the system, you should display a message saying so.
    * Set a student's grade: If the correct administrator's password is given, the student's information should be updated (or added if they aren't already there).

    The programs will have to store all of the grade data in a variable. The entry for a single student will be a list like this:
    [ "userid", 10, "Comments" ]

    The first entry in the list is the student's userid, the second is their mark (an integer) and the last is a string containing comments.

    The entire grade list will be a list of these. So, it's a list of lists and you'll have to work with this data structure. For example, this loop will output the userids of all the students in the grade list grades:

    for entry in data:
    print entry[0]

    This is what they suggested us to do..
    1.Create the initial XHTML page with the forms.
    2.Write a program that uses the gradelist module to load the data. Print out all of the userids. This doesn't have to be a web script (yet). Use the sample data file for testing.
    3.Modify the program so that it outputs XHTML code and can be used as a web script. Add checking for the administrator's password and an error if it's incorrect.
    4.Add printing of the user's mark and comments to this script.
    5.Make a copy of the "view all" script and modify it so it only outputs one user's mark. Remove the password checking.
    6.Write a program that reads the new grade from the form and outputs it to the XHTML page.
    7.Modify the program so it always appends the new data to the end of the list (even if the user is already in the system).
    8.Modify the program so it check s to if the user is already there. If they are, overwrite the old data instead of creating a new entry.
    9.Go back to the two programs that output data and make sure they convert <,> and & to entities. Test this by entering a comment like "Used the <h1> & <h2> tags." The rest of the page shouldn't turn into a heading when this is displayed.
    10.Check the XHTML produced by all of the pages to make sure it's valid.

    I think all i need to get the program to output the grades after entering 165 then i hsould be fine...
  8. #20
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Bombay, India
    Posts
    159
    Rep Power
    12
    I'm don't know anything abt XHTML When do you've to submit your project anyway...guess someone around wld help you out! Am feeling bad as I can't help you out... but Jack the python code that you had written out was right The logic and everything else was proper... Guess theres something with the XHTML scripting or soemthing...not sure

    Subha
  10. #21
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    nonono, dont worry about xhtml.. i ran my old code.. and it said "unscriptbably something" cause of the entry[0]..
    if you could help me out with just python and ignore the xhtml, that would be great.. and it's due on monday.. 11:59 pst.. but i just wanna get started since im stuck
  12. #22
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Bombay, India
    Posts
    159
    Rep Power
    12
    Am sorry got to leave...sat eve here... Netytan/Grim cld help you out.... calling Moderator n Grim ...help out plss..

    Have hope Jack,
    Subha
  14. #23
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    Noooooo,.... T_T well thanks for your help anyways..
    calling 911..rescuers come plz~
  16. #24
  17. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    No-one seems to have mentioned how are you storing the data i.e. in a file? In which case you should post a sample so we know we're working with. Also could you also attach your gradelist module.

    Anyway it seems like pretty simple problem so it shouldn't take long to sort out once we have all the details . If you want to contact me via MSN go right ahead.

    Is this a homework assignment for college?

    Mark.
    programming language development: www.netytan.com Hula

  18. #25
  19. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Originally Posted by NewPythoner
    Am sorry got to leave...sat eve here... Netytan/Grim cld help you out.... calling Moderator n Grim ...help out plss..
    Sorry for the slow reply New, I've been out of town for a few days but I'm back on the case now .
    programming language development: www.netytan.com Hula

  20. #26
  21. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    I just have a quick question. Why are you doing input("Administration Password: ")? Input is for integers raw_input is for strings. Are you using input because you are assuming the user will always enter numbers for the password?
  22. #27
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    Yay backup has arrived
    okok so here's the gradelist module..

    Code:
    import pickle
    filename = "grades.data"
    
    def write(gradelist):
        """
        Write the data from gradelist to a file.
        This overwrites any data currently in the file.
        """
        # check the passed data to ensure it's the right type
        if type(gradelist)!=type([]):
            raise("write: gradelist isn't a list.")
        num = 0
        for entry in gradelist:
            if type(entry)!=type([]):
                raise("write: Entry "+ str(num) + " isn't a list.")
            if len(entry)!=3:
                raise("write: Entry "+ str(num) + " is wrong length.")
            if type(entry[0])!=type(""):
                raise("write: Userid in entry "+ str(num) + "  isn't a string.")
            if type(entry[1])!=type(1):
                raise("write: Grade in entry "+ str(num) + " isn't an integer.")
            if type(entry[2])!=type(""):
                raise("write: Comment in entry "+ str(num) + " isn't a string.")
            num=num+1
    
        # let the pickle module do the hard work...
        fh = open(filename, "w")
        pickle.dump(gradelist, fh)
        fh.close()
    
    def read():
        """
        Read the gradelist file and return the list.
        """
        # open the file and load the data
        try:
            fh = open(filename, "r")
        except:
            return []
        gradelist = pickle.load(fh)
        fh.close()
    
        # check the loaded data to ensure it's the right type
        if type(gradelist)!=type([]):
            raise("read: Stored data isn't a list.")
        num = 0
        for entry in gradelist:
            if type(entry)!=type([]):
                raise("read: Entry "+ str(num) + " isn't a list.")
            if len(entry)!=3:
                raise("read: Entry "+ str(num) + " is wrong length.")
            if type(entry[0])!=type(""):
                raise("read: Userid in entry "+ str(num) + "  isn't a string.")
            if type(entry[1])!=type(1):
                raise("read: Grade in entry "+ str(num) + " isn't an integer.")
            if type(entry[2])!=type(""):
                raise("read: Comment in entry "+ str(num) + " isn't a string.")
            num=num+1
    
        return gradelist
    and yea im using input instead of raw because im expecting the pw will be a number.
  24. #28
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    K so right now i have

    Code:
     import gradelist
    data = gradelist.read()
    x = input("Administration Password: ")
    if x == 165:
        print gradelist.write(data)
    else:
        print "Wrong Password"
    and when i type in 165, it outputs "None".. why is that? I have the gradelist module saved in the same folder as my program.. what's wrong?
  26. #29
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    Hmm i think i know what' wrong.. is it because i haven't gotten the program to read the data file? how do i do that?
  28. #30
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    K cool, I figured out how to output the users in data.. sweeeeeeet

IMN logo majestic logo threadwatch logo seochat tools logo