Re: [Tutor] Bug

2017-05-17 Thread Cameron Simpson
On 17May2017 12:26, Grace Sanford wrote: Theoretically, the following code is suppose to check if the user has won a tic tac toe game by checking if there are all "X"s in either the horizontal, vertical, or diagonal lines of a grid (represented by a list with "board" with elements 0-8). If one

Re: [Tutor] Bug

2017-05-17 Thread Alan Gauld via Tutor
On 17/05/17 17:26, Grace Sanford wrote: > with "board" with elements 0-8). If one of these is the case, it is > suppose to print the "You won" string. Nevertheless, when I change list > variable to reflect one of these conditions, there is no printing > occurring. I cannot figure out why. You

[Tutor] Bug

2017-05-17 Thread Grace Sanford
Theoretically, the following code is suppose to check if the user has won a tic tac toe game by checking if there are all "X"s in either the horizontal, vertical, or diagonal lines of a grid (represented by a list with "board" with elements 0-8). If one of these is the case, it is suppose to print

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Alan Gauld
"Dragos Ionescu" <[EMAIL PROTECTED]> wrote David try this: score = input("What is your exam score: (0-100)? ") No, please don't! input has several security issues, it is much better to use raw_input but convert the result to the type you need: score = int(raw_input("What is your exam sc

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Alan Gauld
"David" <[EMAIL PROTECTED]> wrote When I run it from the idle it works perfect, but when I run it from a file I get none, why is that? score = 66 Here you directly assign a number to score #!/usr/bin/python score = raw_input("What is your exam score: (0-100)? ") Here you assign a str

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote It's not too bad but I would probably use a dictionary rather than the list - which avoids the index problem Not sure how the dict is better - in either case, leaving off the grade corresponding to a score of 100 will raise an exception. Sure, you co

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Steve Willoughby
Dragos Ionescu wrote: Original Message From: Steve Willoughby <[EMAIL PROTECTED]> To: Dragos Ionescu <[EMAIL PROTECTED]> Cc: bob gailer <[EMAIL PROTECTED]>; David <[EMAIL PROTECTED]>; tutor@python.org Sent: Saturday, October 4, 2008 11:04:30 PM Subject: Re: [

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Dragos Ionescu
Original Message From: Steve Willoughby <[EMAIL PROTECTED]> To: Dragos Ionescu <[EMAIL PROTECTED]> Cc: bob gailer <[EMAIL PROTECTED]>; David <[EMAIL PROTECTED]>; tutor@python.org Sent: Saturday, October 4, 2008 11:04:30 PM Subject: Re: [Tutor] bug in exam score co

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Steve Willoughby
Dragos Ionescu wrote: - Original Message From: bob gailer <[EMAIL PROTECTED]> To: David <[EMAIL PROTECTED]> Cc: tutor@python.org Sent: Saturday, October 4, 2008 10:15:10 PM Subject: Re: [Tutor] bug in exam score conversion program Lots of good responses. And now f

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Dragos Ionescu
- Original Message From: bob gailer <[EMAIL PROTECTED]> To: David <[EMAIL PROTECTED]> Cc: tutor@python.org Sent: Saturday, October 4, 2008 10:15:10 PM Subject: Re: [Tutor] bug in exam score conversion program Lots of good responses. And now for something completely differ

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread bob gailer
Lots of good responses. And now for something completely different: import string x = string.maketrans('567891', 'FDCBAA') score = raw_input('score>') print "Your grade is:", score[0].translate(x) -- Bob Gailer Chapel Hill NC 919-636-4239 When we take the time to be aware of our feelings and

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Dragos Ionescu
tutor@python.org Sent: Saturday, October 4, 2008 7:55:57 PM Subject: Re: [Tutor] bug in exam score conversion program When I run it from the idle it works perfect, but when I run it from a file I get none, why is that? >>> grades = [  (90,100,'A'),             (80, 89,'B'

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Kent Johnson
On Sat, Oct 4, 2008 at 12:55 PM, David <[EMAIL PROTECTED]> wrote: > When I run it from the idle it works perfect, but when I run it from a > file I get none, why is that? > score = raw_input("What is your exam score: (0-100)? ") The value returned from raw_input() is a string; you have to convert

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread David
When I run it from the idle it works perfect, but when I run it from a file I get none, why is that? >>> grades = [ (90,100,'A'), (80, 89,'B'), (70, 79,'C'), (60, 69,'D'), ( 0, 59,'F'), ] >>> score = 66 >>> def getGrade(score): """

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Kent Johnson
On Sat, Oct 4, 2008 at 9:45 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: > It's not too bad but I would probably use a dictionary rather > than the list - which avoids the index problem Not sure how the dict is better - in either case, leaving off the grade corresponding to a score of 100 will raise

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Kent Johnson
On Sat, Oct 4, 2008 at 10:31 AM, Brian C. Lane <[EMAIL PROTECTED]> wrote: >for g in grades: >if (score <= g[1]) and (score >= g[0]): >return g[2] I think tuple unpacking makes code like this more readable: for lower, upper, grade in grades: if lower <= score <= upper:

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Alan Gauld
"Brian C. Lane" <[EMAIL PROTECTED]> wrote # min, max, grade grades = [ (90,100,'A'), (80, 89,'B'), (70, 79,'C'), (60, 69,'D'), ( 0, 59,'F'), ] def getGrade(score): """ Return a letter grade based on a score """ for g in grades:

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Brian C. Lane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David wrote: > Hello!! > > I just completed exercise 7 (chapter 4) in Zelle's book: > "A certain CS professor gives 100-point exams that are graded on the > scale 90–100:A, 80–89:B, 70–79:C, 60–69:D, 60:F. Write a program that > accepts an exam score

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Alan Gauld
"David" <[EMAIL PROTECTED]> wrote I am quite happy with my code, but there is a bug: if the score is 100, then the program calculates 100/10 = 10. However, the tuple runs to 9, leaving me with an error message: IndexError: tuple index out of range I can't figure out how to solve that problem

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread W W
On Sat, Oct 4, 2008 at 5:11 AM, David <[EMAIL PROTECTED]> wrote: > Hello!! I can't figure out how to solve that problem... > I also suspect that my code clearly exposes me as a beginner :-) What would > be the pythonic way of solving that exercise? > > # exam score to grade conversion > # Zelle

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Sander Sweers
On Sat, Oct 4, 2008 at 12:11, David <[EMAIL PROTECTED]> wrote: > I am quite happy with my code, but there is a bug: if the score is 100, then > the program calculates 100/10 = 10. However, the tuple runs to 9, leaving me > with an error message: IndexError: tuple index out of range > > I can't figu

[Tutor] bug in exam score conversion program

2008-10-04 Thread David
Hello!! I just completed exercise 7 (chapter 4) in Zelle's book: "A certain CS professor gives 100-point exams that are graded on the scale 90–100:A, 80–89:B, 70–79:C, 60–69:D, 60:F. Write a program that accepts an exam score as input and prints out the corresponding grade." I am quite happy

Re: [Tutor] bug or feature

2007-06-01 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Just the way IDLE works. Unexpected, but certainly not a bug, I'd say. Andreas Grant Hagstrom wrote: > A bug or feature in the IDLE of python 2.5? > > pre-step: save the following file to your computer: > # file mylist.py > jobs = [ > 'Lions

[Tutor] bug or feature

2007-06-01 Thread Grant Hagstrom
A bug or feature in the IDLE of python 2.5? pre-step: save the following file to your computer: # file mylist.py jobs = [ 'Lions', 'SysTest', 'trainDD', 'Cats', 'train', 'sharks', 'whale', ] Step 1. copy, paste this script into the idle wi

Re: [Tutor] Bug in python, or is it just 3am

2006-04-21 Thread Liam Clarke
Hi Ryan, I see what confused you; the " >>> number + 1 6 >>> print number 5 " part. Yeah, it's only evaluating the the first one. So you're asking it "What's number + 1"? Whereas, >>> number = number + 1 or >>> number += 1 Is saying "Make number equal number plus 1" Ha, it's all a learning

Re: [Tutor] Bug in python, or is it just 3am

2006-04-21 Thread Alan Gauld
> But when i use a number = number + 1 > right after the value stays the same, I'm not sure what you mean by that. > Now i thought that number = number + 1 just wasn't > vailed in python untill i tried it again and it > worked, variable = variable + 1 is perfectly valid. It is not the normal ma

Re: [Tutor] Bug in python, or is it just 3am

2006-04-21 Thread Danny Yoo
On Fri, 21 Apr 2006, ryan luna wrote: > HA! ignore me, im stupid, XD i knew i should have waited untill morning > =P, No bug, the number = number was just point to the old number which > was one number lower, sorry. night =P Get some sleep. *grin*

[Tutor] Bug in python, or is it just 3am

2006-04-21 Thread ryan luna
HA! ignore me, im stupid, XD i knew i should have waited untill morning =P, No bug, the number = number was just point to the old number which was one number lower, sorry. night =P Oh i see someone replied -_- sorry lol ___ Tutor maillist - Tutor@py

[Tutor] Bug in python, or is it just 3am

2006-04-21 Thread ryan luna
Hey everyone, i believe i might have found a bug in python? im not sure, heres a screen shot. http://img151.imageshack.us/img151/4268/pythonbug8by.jpg When i type number + 1 and print it, It adds one, But when i use a number = number + 1 right after the value stays the same, Now i thought that numb

Re: [Tutor] Bug in python

2006-02-21 Thread Hugo González Monteverde
Hi, just a recommendation: try not to assume a bug beforehand, that's a quick way to get flames or just get plain ignored, especially in a list for beginners. > The * is being given equal priority to %. > > Why isn't % given higher priority than *? Why should it? Doesn't it make sense that as

Re: [Tutor] Bug in python

2006-02-19 Thread Alan Gauld
8*a%2 > 0 > > The * is being given equal priority to %. > > Why isn't % given higher priority than *? Because that's the way Guido designed I guess. ;-) Although why would you expect % to be higher precedence than *? You can always use parentheses, and if in any doubt should do so. > A

[Tutor] Bug in python

2006-02-19 Thread John Fouhy
On 20/02/06, Kermit Rose <[EMAIL PROTECTED]> wrote: > >>> 8*a%2 > 0 > The * is being given equal priority to %. > > Why isn't % given higher priority than *? Calling it a bug is a bit harsh when it's documented that way :-) See: http://docs.python.org/ref/summary.html *, / and % all have the sa

[Tutor] Bug in python

2006-02-19 Thread Kermit Rose
>>> a = 1 >>> a2 = a%2 >>> a2 1 >>> 8*a2 8 >>> 8*(a%2) 8 >>> 8*a%2 0 >>> The * is being given equal priority to %. Why isn't % given higher priority than *? Also, why am I getting a syntax error in the following? The def in the definition of the second function is being highlighted. IDLE