Python Simple program
Roy Smith
roy at panix.com
Sat Jan 18 13:27:28 EST 2014
In article <a2e2f4a7-4c86-440e-839f-09745735efe0 at googlegroups.com>,
indar kumar <indarkumar59 at gmail.com> wrote:
> Hello, I am a newbie. Can somebody help me write the code for following
> program?
>
>
> Write a program that takes student grades and prints out the GPA. The
> information is input, one student per line in the format: <student id>
> <course1 grade> <course2 grade> ...
> The number of students is not known in advance. You should prompt the user
> for more until they enter an empty line. The number of courses per student
> varies and is also not known in advance. You should read as many grades as
> are entered on the line.
This sounds like a homework problem for a basic programming course.
Rather than write your program for you, let me give you a few broad
hints. You're going to need to call raw_imput() in a loop to read in
your data, then use split() to break the line up into fields, and
another loop to iterate over the individual grades.
See what progress you can make with that, and if you get stuck, come
back with whatever code you've written so far, and more specific
questions.
More information about the Python-list
mailing list