Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64273 > unrolled thread
| Started by | indar kumar <indarkumar59@gmail.com> |
|---|---|
| First post | 2014-01-18 18:23 -0800 |
| Last post | 2014-01-19 20:05 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
Help with simple code that has database defined indar kumar <indarkumar59@gmail.com> - 2014-01-18 18:23 -0800
Re: Help with simple code that has database defined Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-18 23:14 -0500
Re: Help with simple code that has database defined Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-19 20:05 +0000
| From | indar kumar <indarkumar59@gmail.com> |
|---|---|
| Date | 2014-01-18 18:23 -0800 |
| Subject | Help with simple code that has database defined |
| Message-ID | <4ea55e83-cfcd-4aaf-824a-3e3bced921c2@googlegroups.com> |
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.
[toc] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2014-01-18 23:14 -0500 |
| Message-ID | <mailman.5700.1390104849.18130.python-list@python.org> |
| In reply to | #64273 |
On Sat, 18 Jan 2014 18:23:01 -0800 (PST), indar kumar
<indarkumar59@gmail.com> declaimed the following:
>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>
>
This is your third request in 24 hours... You've gone from a
description of just simple one-line inputs to produce a simple GPA output
up to something with persistence (meaning you need to have a data file of
some sort between invocations of the program), and additional data fields.
>Kindly help.
As you've been told, we do NOT do homework assignments (and if this is
NOT a homework assignment but an actual application for keeping student
grades for some school I strongly recommend you give them back whatever
money they paid you).
Ask a question about some aspect of Python that may not be understood,
and we'll give you an answer. "I need a program that does xyz, help!" will
not produce any results -- that's your job to do.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2014-01-19 20:05 +0000 |
| Message-ID | <lbhb6d$smo$3@dont-email.me> |
| In reply to | #64273 |
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, denismfmcmahon@gmail.com
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web