Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help with simple code that has database defined

19 views
Skip to first unread message

indar kumar

unread,
Jan 18, 2014, 9:23:01 PM1/18/14
to
I have to save students information in a database that is keeping continuously track of the information. Format is as follows:
Information: <name> <course> <grade> <duration>

Note: if this name already exists there in database, just update the information of that(name) e.g course,grade and date. Otherwise, add it.

What I think:

Database={} #First Created a dictionary that will keep track
z = "Enter student name, course, grade and duration: "
line = raw_input(z)
while (line != "quit"):
data = line.split()
name = data[0]
line = raw_input(z)

This is just part because this is what I know how to do, for rest have no idea

The output should be like this:
{'alex': ['7', '8', '6'], 'john': ['9', '8', '7']})

Now as program will continuously prompt for input. If user enters “quit” it would exit. Otherwise it keeps taking input.

Now if there is already a name existing for example “alex” and his course, grade and duration are 7,8,6. Now in next turn of input if user again enters the name as alex but different entries for him e.g 9,9,9 so it should replace the older info by new e.g. it should replace 7,8,6 for alex by 9,9,9 and if user enters a entirely new name that is not in dictionary then it should be added to dictionary for example nancy 6 6 6 is the input then output should be:

{'alex': ['7', '8', '6'], 'john': ['9', '8', '7'],’nancy’:[‘6’,’6’,’6’]})


Kindly help.
Message has been deleted

Denis McMahon

unread,
Jan 19, 2014, 3:05:33 PM1/19/14
to
On Sat, 18 Jan 2014 18:23:01 -0800, indar kumar wrote:

> I have to save students information in a database that is keeping
> continuously track of the information. Format is as follows:

You probably need to use one of the database modules.

> Note: if this name already exists there in database, just update the
> information of that(name) e.g course,grade and date. Otherwise, add it.

That sounds like an sql issue specific to your chosen database, not a
python issue.

> This is just part because this is what I know how to do, for rest have
> no idea

I suggest you get idea fast. Or ask your lecturers for advice. Or return
the advance you were paid on this coding job, because you don't seem to
have the skills to do it.

--
Denis McMahon, denismf...@gmail.com
0 new messages