Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.06; 'scale.': 0.07; 'string': 0.09; '3),': 0.09; 'exit': 0.09; 'input,': 0.09; 'kumar': 0.09; 'oh,': 0.09; 'output,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'separating': 0.09; 'jan': 0.12; 'random': 0.14; '"*"': 0.16; '":"': 0.16; '(before': 0.16; '334': 0.16; '50)': 0.16; '>the': 0.16; 'averaging': 0.16; 'format:': 0.16; 'gur': 0.16; 'hint:': 0.16; 'homework...': 0.16; 'incorrect': 0.16; 'integer,': 0.16; 'message-id:@4ax.com': 0.16; 'ner': 0.16; 'program?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:program': 0.16; 'varies': 0.16; 'sat,': 0.16; 'student': 0.16; '3.0': 0.19; 'advance.': 0.19; 'entered': 0.20; 'input': 0.22; 'id:': 0.23; 'form:': 0.24; 'integer': 0.24; 'skip:e 30': 0.24; 'url:home': 0.24; 'math': 0.24; '2.0': 0.26; 'header:X -Complaints-To:1': 0.27; 'point': 0.28; 'points': 0.29; 'gives': 0.31; 'code': 0.31; '4.0': 0.31; 'prints': 0.31; 'skip:* 50': 0.31; 'class': 0.32; 'covered': 0.32; 'skip:c 30': 0.32; 'summary': 0.32; 'supposed': 0.32; 'another': 0.32; 'text': 0.33; 'problem': 0.35; 'point.': 0.35; 'version': 0.36; 'done,': 0.36; 'subject:Simple': 0.36; 'entry': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'so,': 0.37; 'list': 0.37; 'expected': 0.38; 'form,': 0.38; 'somebody': 0.38; 'to:addr:python-list': 0.38; 'generating': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'blank': 0.60; 'letters': 0.60; 'problems.': 0.60; 'skip:y 20': 0.60; 'conversion': 0.61; 'name:': 0.61; 'course': 0.61; 'simple': 0.61; 'first': 0.61; "you've": 0.63; 'show': 0.63; 'information': 0.63; 'name': 0.63; 'real': 0.63; 'map': 0.64; 'more': 0.64; 'prompt': 0.68; 'press': 0.70; '100%': 0.77; '100': 0.79; '95%': 0.84; 'ine': 0.84; 'percents': 0.84; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Python Simple program Date: Sat, 18 Jan 2014 15:25:32 -0500 Organization: IISS Elusive Unicorn References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-79-218-90.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 145 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390076740 news.xs4all.nl 2887 [2001:888:2000:d::a6]:39787 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64251 On Sat, 18 Jan 2014 10:00:47 -0800 (PST), indar kumar declaimed the following: >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: ... >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 smells like formal homework... So show us what you've done, and where you are having problems. Everything in the problem description should have been covered by the class at this point. Hint: the above description requires the use of an indefinite loop, console input, console output, string manipulation, conversion of text input to numbers, another loop of some form, some simple math (addition and division), and list structures Unknowns: are course grades provided in 0-100% (if so, what %s map to what GPA -- oh, is GPA 0-4 or 0-5; integer or real results), letters (A, B, C, D, E or F), or some other scale. What is a student ID -- some pseudo random integer, a first name, first&last name, some ad-hoc string? Are you supposed to collect all the inputs, and then produce a report with all the GPAs... Or are you going to be generating a GPA for each entered line as it is entered (mixing the input with the output). I did just produce a version using REXX that gives this output: -=-=-=-=-=- C:\Users\Wulfraed\Documents>homework.rx Enter data in the form: student ID: g1 g2 g3 ... gn Note the : separating the ID from the grades Grades are expected to be integer percents from 0 to 100% Enter a blank line to exit data entry Enter student data (blank to exit): 123: 92 75 83 88 Enter student data (blank to exit): 334: 67 79 40 Enter student data (blank to exit): see a Name: 125 99 89 92 78 Enter student data (blank to exit): ************************************************** * Gradebook Summary Report * ************************************************** Student ID GPA 123 2.450 334 0.867 see a Name 3.160 ************************************************** Press ENTER key to exit... C:\Users\Wulfraed\Documents> -=-=-=-=-=- Of course, I may have the conversion from % to grade point incorrect (before averaging the grade points -- should 95% be a grade point of 4.0 or 3.5? on a 4pt scale) -=-=-=-=- /* ERKK onfrq irefvba bs Clguba ubzrjbex nffvtazrag */ fnl "Ragre qngn va gur sbez:" fnl " fghqrag VQ: t1 t2 t3 ... ta" fnl "Abgr gur : frcnengvat gur VQ sebz gur tenqrf" fnl "Tenqrf ner rkcrpgrq gb or vagrtre crepragf sebz 0 gb 100%" fnl "Ragre n oynax yvar gb rkvg qngn ragel" fnl " " tenqrobbx. = "" tenqrobbx.0 = 0 qb sberire fnl " " fnl "Ragre fghqrag qngn (oynax gb rkvg): " cnefr chyy fghqragqngn vs fghqragqngn = "" gura yrnir cnefr ine fghqragqngn VQ ":" tenqrf fghqrag = tenqrobbx.0 + 1 fpber = 0.0 pbhag = 0 qb juvyr tenqrf <> "" cnefr ine tenqrf tenqr tenqrf fryrpg jura tenqr > 100 gura TC = 4.0 jura tenqr > 90 gura TC = 3.0 + ((tenqr - 90) / 10) jura tenqr > 80 gura TC = 2.0 + ((tenqr - 80) / 10) jura tenqr > 70 gura TC = 1.0 + ((tenqr - 70) / 10) jura tenqr > 60 gura TC = 0.0 + ((tenqr - 60) / 10) bgurejvfr TC = 0.0 raq fpber = fpber + TC pbhag = pbhag + 1 raq vs pbhag > 0 gura nit = fpber / pbhag ryfr nit = 0.0 tenqrobbx.fghqrag.vqrag = VQ tenqrobbx.fghqrag.tcn = nit tenqrobbx.0 = fghqrag raq fnl pbcvrf("*", 50) fnl "*" || pragre("Tenqrobbx Fhzznel Ercbeg", 48) || "*" fnl pbcvrf("*", 50) fnl yrsg("Fghqrag VQ", 25) || evtug("TCN", 25) fnl "" qb fghqrag = 1 gb tenqrobbx.0 fnl yrsg(tenqrobbx.fghqrag.vqrag, 25) || evtug(sbezng(tenqrobbx.fghqrag.tcn, 1, 3), 25) raq fnl "" fnl pbcvrf("*", 50) -=-=-=-=- -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/