Re: on writing a while loop for rolling two dice

2021-09-19 Thread Hope Rouselle
dn writes: [...] > Further, if you look at the OP's original solution, it only publishes > the last pair, ie the match, without mention of the list of non-matches. > Was it perhaps only a means of testing the solution? It was a means of showing the student that indeed they obtained a match. If

Re: on floating-point numbers

2021-09-08 Thread Hope Rouselle
Joe Pfeiffer writes: > Hope Rouselle writes: >> Christian Gollwitzer writes: >>> >>> I believe it is not commutativity, but associativity, that is >>> violated. >> >> Shall we take this seriously? (I will disagree, but that doesn't mean I

Re: on writing a while loop for rolling two dice

2021-09-07 Thread Hope Rouselle
Grant Edwards writes: > On 2021-09-06, Stefan Ram wrote: >> "Avi Gross" writes: >>> In languages like C/C++ there are people who make up macros like: >>>#define INDEFINITELY_LOOP while (true) >>>Or something like that and then allow the preprocessor to replace >>>INDEFINITELY_LOOP with valid C

Re: on floating-point numbers

2021-09-06 Thread Hope Rouselle
Chris Angelico writes: > On Sun, Sep 5, 2021 at 1:04 PM Hope Rouselle wrote: >> The same question in other words --- what's a trivial way for the REPL >> to show me such cycles occur? >> >> >>>>>> 7.23.as_integer_ratio() >> >>> (2

Re: on floating-point numbers

2021-09-06 Thread Hope Rouselle
"Peter J. Holzer" writes: > On 2021-09-05 03:38:55 +1200, Greg Ewing wrote: >> If 7.23 were exactly representable, you would have got >> 723/1000. >> >> Contrast this with something that *is* exactly representable: >> >> >>> 7.875.as_integer_ratio() >> (63, 8) >> >> and observe that 7875/1000

Re: on writing a while loop for rolling two dice

2021-09-04 Thread Hope Rouselle
"Michael F. Stemper" writes: > On 04/09/2021 08.53, Hope Rouselle wrote: >> Chris Angelico writes: > >>> And at this point, it's looking pretty much identical to the for loop >>> version. Ultimately, they're all the same and you can pick a

Re: Problem with python

2021-09-04 Thread Hope Rouselle
Igor Korot writes: > Hi, > Will this syntax work in python 2? If you say print(something) it works in both. So, stick to this syntax. -- https://mail.python.org/mailman/listinfo/python-list

Re: on floating-point numbers

2021-09-04 Thread Hope Rouselle
Christian Gollwitzer writes: > Am 04.09.21 um 14:48 schrieb Hope Rouselle: >> Christian Gollwitzer writes: >> >>> Am 02.09.21 um 15:51 schrieb Hope Rouselle: >>>> Just sharing a case of floating-point numbers. Nothing needed to be >>>>

Re: on floating-point numbers

2021-09-04 Thread Hope Rouselle
Julio Di Egidio writes: [...] >> I, too, lost my patience there. :-) > > As if I didn't know who's trolling... I never trolled you. When we had our conversations in sci.logic, I was Boris Dorestand --- you would remember if you have very good memory. We talked for just a few days, I guess. T

Re: on floating-point numbers

2021-09-04 Thread Hope Rouselle
Hope Rouselle writes: > Greg Ewing writes: > >> On 5/09/21 2:42 am, Hope Rouselle wrote: >>> Here's what I did on this case. The REPL is telling me that >>>7.23 = 2035064081618043/281474976710656 >> >> If 7.23 were exactly representable, you

Re: on floating-point numbers

2021-09-04 Thread Hope Rouselle
Richard Damon writes: > On 9/4/21 9:40 AM, Hope Rouselle wrote: >> Chris Angelico writes: >> >>> On Fri, Sep 3, 2021 at 4:58 AM Hope Rouselle wrote: >>>> >>>> Hope Rouselle writes: >>>> >>>>> Just sharing a case of

Re: on floating-point numbers

2021-09-04 Thread Hope Rouselle
Greg Ewing writes: > On 5/09/21 2:42 am, Hope Rouselle wrote: >> Here's what I did on this case. The REPL is telling me that >>7.23 = 2035064081618043/281474976710656 > > If 7.23 were exactly representable, you would have got > 723/1000. > > Contrast th

Re: on floating-point numbers

2021-09-04 Thread Hope Rouselle
Julio Di Egidio writes: > On Thursday, 2 September 2021 at 15:52:02 UTC+2, Hope Rouselle wrote: > >> I don't understand floating-point numbers from the inside out, but I do >> know how to work with base 2 and scientific notation. So the idea of >> expressing a numb

Re: on writing a while loop for rolling two dice

2021-09-04 Thread Hope Rouselle
"Peter J. Holzer" writes: > On 2021-09-02 11:28:21 -0300, Hope Rouselle wrote: >> dn writes: >> > On 29/08/2021 08.46, Hope Rouselle wrote: >> >> Here's my solution: >> >> >> >> --8<---cut here--

Re: on floating-point numbers

2021-09-04 Thread Hope Rouselle
Julio Di Egidio writes: > On Thursday, 2 September 2021 at 16:51:24 UTC+2, Christian Gollwitzer wrote: >> Am 02.09.21 um 16:49 schrieb Julio Di Egidio: >> > On Thursday, 2 September 2021 at 16:41:38 UTC+2, Peter Pearson wrote: >> >> On Thu, 02 Sep 2021 10:51

Re: on writing a while loop for rolling two dice

2021-09-04 Thread Hope Rouselle
Chris Angelico writes: > On Fri, Sep 3, 2021 at 4:33 AM Hope Rouselle wrote: >> Yeah. Here's a little context. I came across this by processing a list >> of exercises. (I'm teaching a course --- you know that by now, I >> guess.) So the first thing I observ

Re: on floating-point numbers

2021-09-04 Thread Hope Rouselle
Christian Gollwitzer writes: > Am 02.09.21 um 15:51 schrieb Hope Rouselle: >> Just sharing a case of floating-point numbers. Nothing needed to be >> solved or to be figured out. Just bringing up conversation. >> (*) An introduction to me >> I don't understand

Re: on floating-point numbers

2021-09-04 Thread Hope Rouselle
Chris Angelico writes: > On Fri, Sep 3, 2021 at 4:58 AM Hope Rouselle wrote: >> >> Hope Rouselle writes: >> >> > Just sharing a case of floating-point numbers. Nothing needed to be >> > solved or to be figured out. Just bringing up conversati

Re: on the popularity of loops while and for

2021-09-04 Thread Hope Rouselle
"Peter J. Holzer" writes: > On 2021-08-29 10:04:47 +0100, Barry wrote: >> > I'd like get a statistic of how often each loop is used in practice. >> > >> > I was trying to take a look at the Python's standard libraries --- those >> > included in a standard installation of Python 3.9.6, say ---

Re: on floating-point numbers

2021-09-04 Thread Hope Rouselle
Chris Angelico writes: > On Fri, Sep 3, 2021 at 4:29 AM Hope Rouselle wrote: >> >> Just sharing a case of floating-point numbers. Nothing needed to be >> solved or to be figured out. Just bringing up conversation. >> >> (*) An introduction to me >> >&

Re: on perhaps unloading modules?

2021-09-04 Thread Hope Rouselle
Dennis Lee Bieber writes: > On Sun, 22 Aug 2021 16:28:12 -0300, Hope Rouselle > declaimed the following: > > >>That's wild. :-) Was this created by Brian Kernighan? It's hard to >>believe. Oh, I think he wrote AMPL, wasn't it? A Mathematical >>

Re: on floating-point numbers

2021-09-02 Thread Hope Rouselle
Hope Rouselle writes: > Just sharing a case of floating-point numbers. Nothing needed to be > solved or to be figured out. Just bringing up conversation. > > (*) An introduction to me > > I don't understand floating-point numbers from the inside out, but I do > know h

Re: on writing a while loop for rolling two dice

2021-09-02 Thread Hope Rouselle
Chris Angelico writes: > On Mon, Aug 30, 2021 at 11:13 PM David Raymond > wrote: >> >> > def how_many_times(): >> > x, y = 0, 1 >> > c = 0 >> > while x != y: >> > c = c + 1 >> > x, y = roll() >> > return c, (x, y) >> >> Since I haven't seen it used in answers yet, here's another

Re: on the popularity of loops while and for

2021-09-02 Thread Hope Rouselle
Terry Reedy writes: > On 8/28/2021 9:31 AM, Hope Rouselle wrote: >> I'd like get a statistic of how often each loop is used in practice. > > My guess is that for loops are at least twice as common as while loops. Scanning just the Python 3.9.6's Lib/ directory --- usi

Re: on the popularity of loops while and for

2021-09-02 Thread Hope Rouselle
Chris Angelico writes: > On Sun, Aug 29, 2021 at 7:40 AM Hope Rouselle wrote: >> >> I'd like get a statistic of how often each loop is used in practice. >> >> I was trying to take a look at the Python's standard libraries --- those >> included in a

Re: on writing a while loop for rolling two dice

2021-09-02 Thread Hope Rouselle
David Raymond writes: >> def how_many_times(): >> x, y = 0, 1 >> c = 0 >> while x != y: >> c = c + 1 >> x, y = roll() >> return c, (x, y) > > Since I haven't seen it used in answers yet, here's another option using our > new walrus operator > > def how_many_times(): > roll_co

Re: on writing a while loop for rolling two dice

2021-09-02 Thread Hope Rouselle
dn writes: > On 29/08/2021 08.46, Hope Rouselle wrote: >> Here's my solution: >> >> --8<---cut here---start->8--- >> def how_many_times(): >> x, y = 0, 1 >> c = 0 >> while x != y: >> c =

on floating-point numbers

2021-09-02 Thread Hope Rouselle
Just sharing a case of floating-point numbers. Nothing needed to be solved or to be figured out. Just bringing up conversation. (*) An introduction to me I don't understand floating-point numbers from the inside out, but I do know how to work with base 2 and scientific notation. So the idea of

Re: on the popularity of loops while and for

2021-09-02 Thread Hope Rouselle
Barry writes: >> On 28 Aug 2021, at 22:42, Hope Rouselle wrote: >> >> I'd like get a statistic of how often each loop is used in practice. >> >> I was trying to take a look at the Python's standard libraries --- those >> included in a standar

Re: on the popularity of loops while and for

2021-08-28 Thread Hope Rouselle
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Hope Rouselle writes: >>Have you guys ever measured something like that in a casual or serious > > import ast > import pathlib > rootname=r'''''' > rootpath=pathlib.Path(rootname) > rootiter

Re: on writing a while loop for rolling two dice

2021-08-28 Thread Hope Rouselle
Hope Rouselle writes: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > >> Hope Rouselle writes: >>>How would you write this? >> >> """Rolls two dice until both yield the same value. >> Returns the number of times the two dice were rolle

Re: on writing a while loop for rolling two dice

2021-08-28 Thread Hope Rouselle
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Hope Rouselle writes: >>How would you write this? > > """Rolls two dice until both yield the same value. > Returns the number of times the two dice were rolled > and the final value yielded.""

Re: on writing a while loop for rolling two dice

2021-08-28 Thread Hope Rouselle
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Hope Rouselle writes: >>Wait, I'm surprised ``outcome'' is still a valid name at the >>return-statement. Wasn't it defined inside the while? Shouldn't its >>scope be restricted to the while block?

on the popularity of loops while and for

2021-08-28 Thread Hope Rouselle
I'd like get a statistic of how often each loop is used in practice. I was trying to take a look at the Python's standard libraries --- those included in a standard installation of Python 3.9.6, say --- to see which loops are more often used among while and for loops. Of course, since English u

on writing a while loop for rolling two dice

2021-08-28 Thread Hope Rouselle
How should I write this? I'd like to roll two six-sided dice until I get the same number on both. I'd like to get the number of times I tried. Here's a primitive I'm using: --8<---cut here---start->8--- >>> x, y = roll() >>> x 6 >>> y 6 # lucky >>> x, y = ro

Re: on perhaps unloading modules?

2021-08-28 Thread Hope Rouselle
"Peter J. Holzer" writes: > On 2021-08-22 16:28:12 -0300, Hope Rouselle wrote: >> I have a certain distaste for syntax too. For instance, I would much >> rather write and read ``first(ls)'' than ``ls[0]''. > > Would you also prefer `twothou

Re: on perhaps unloading modules?

2021-08-23 Thread Hope Rouselle
Dennis Lee Bieber writes: > On Sat, 21 Aug 2021 17:15:14 -0300, Hope Rouselle > declaimed the following: > >>write some PHP precisely because it looked so much more cryptic than >>Allaire ColdFusion. Then C looked even more cryptic, so I fell in love >>with C. >

Re: on perhaps unloading modules?

2021-08-22 Thread Hope Rouselle
Hope Rouselle writes: > Chris Angelico writes: > >> On Tue, Aug 17, 2021 at 4:02 AM Greg Ewing >> wrote: >>> The second best way would be to not use import_module, but to >>> exec() the student's code. That way you don't create an entry in >>

Re: on perhaps unloading modules?

2021-08-21 Thread Hope Rouselle
Chris Angelico writes: > On Sun, Aug 22, 2021 at 4:37 AM Hope Rouselle wrote: >> >> Greg Ewing writes: >> >> > On 21/08/21 1:36 pm, Hope Rouselle wrote: >> >> I wish I could restrict their syntax too, though, but I fear that's >> >>

Re: on perhaps unloading modules?

2021-08-21 Thread Hope Rouselle
Greg Ewing writes: > On 21/08/21 1:36 pm, Hope Rouselle wrote: >> I wish I could restrict their syntax too, though, but I fear that's >> not possible. For instance, it would be very useful if I could >> remove loops. > > Actually you could, using ast.parse

Re: on slices, negative indices, which are the equivalent procedures?

2021-08-20 Thread Hope Rouselle
Hope Rouselle writes: > Hope Rouselle writes: > >> Dennis Lee Bieber writes: >> >>> On Sun, 15 Aug 2021 00:05:29 -0300, Jack Brandom >>> declaimed the following: >>> >>>>Dennis Lee Bieber writes: >>>> >>> &

Re: on slices, negative indices, which are the equivalent procedures?

2021-08-20 Thread Hope Rouselle
Hope Rouselle writes: > Dennis Lee Bieber writes: > >> On Sun, 15 Aug 2021 00:05:29 -0300, Jack Brandom >> declaimed the following: >> >>>Dennis Lee Bieber writes: >>> >> >>>> subscript: '.' '.' '.' |

Re: on perhaps unloading modules?

2021-08-20 Thread Hope Rouselle
Greg Ewing writes: > On 21/08/21 6:15 am, Hope Rouselle wrote: >>>>> code() >> 'def p():\n import math\n return math.e\n' >>>>> exec(code()) >>>>> p >> >>>>> p() >> 2.718281828459045 > > Note tha

Re: on perhaps unloading modules?

2021-08-20 Thread Hope Rouselle
Chris Angelico writes: > On Tue, Aug 17, 2021 at 4:02 AM Greg Ewing > wrote: >> The second best way would be to not use import_module, but to >> exec() the student's code. That way you don't create an entry in >> sys.modules and don't have to worry about somehow unloading the >> module. > > I w

Re: on slices, negative indices, which are the equivalent procedures?

2021-08-20 Thread Hope Rouselle
Dennis Lee Bieber writes: > On Sun, 15 Aug 2021 00:05:29 -0300, Jack Brandom > declaimed the following: > >>Dennis Lee Bieber writes: >> > >>> subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop] >>> sliceop: ':' [test] > >> >>This is looking less readable, so, no, I prefer that previous

Re: some problems for an introductory python test

2021-08-20 Thread Hope Rouselle
Dennis Lee Bieber writes: > On Sun, 15 Aug 2021 00:15:58 -0300, Hope Rouselle > declaimed the following: > > Giganews seems to have just vomited up three days worth of traffic... > >>Dennis Lee Bieber writes: >> >>> >>> Granted, the fac

Re: some problems for an introductory python test

2021-08-19 Thread Hope Rouselle
Chris Angelico writes: > On Tue, Aug 17, 2021 at 3:51 AM Hope Rouselle > wrote: >> >> Chris Angelico writes: >> >> Wow, I kinda feel the same as you here. I think this justifies >> >> perhaps >> >> using a hardware solution. (Crazy id

Re: on perhaps unloading modules?

2021-08-19 Thread Hope Rouselle
Martin Di Paola writes: > This may not answer your question but it may provide an alternative > solution. > > I had the same challenge that you an year ago so may be my solution will > work for you too. > > Imagine that you have a Markdown file that *documents* the expected > results. > > This

Re: on perhaps unloading modules?

2021-08-19 Thread Hope Rouselle
Chris Angelico writes: > On Tue, Aug 17, 2021 at 4:02 AM Greg Ewing > wrote: >> The second best way would be to not use import_module, but to >> exec() the student's code. That way you don't create an entry in >> sys.modules and don't have to worry about somehow unloading the >> module. > > I wo

Re: on perhaps unloading modules?

2021-08-16 Thread Hope Rouselle
Hope Rouselle writes: > Hope Rouselle writes: > > [...] > >> Of course, you want to see the code. I need to work on producing a >> small example. Perhaps I will even answer my own question when I do. > > [...] > > Here's a small-enough case.

Re: on perhaps unloading modules?

2021-08-16 Thread Hope Rouselle
Hope Rouselle writes: [...] > Of course, you want to see the code. I need to work on producing a > small example. Perhaps I will even answer my own question when I do. [...] Here's a small-enough case. We have two students here. One is called student.py and the other is call

Re: on perhaps unloading modules?

2021-08-16 Thread Hope Rouselle
Greg Ewing writes: > On 16/08/21 1:50 am, Hope Rouselle wrote: >> By the way, I'm aware that what I'm doing here is totally unsafe and I >> could get my system destroyed. I'm not planning on using this --- thank >> you for your concern. I'm ju

on perhaps unloading modules?

2021-08-16 Thread Hope Rouselle
(*) Introduction By the way, I'm aware that what I'm doing here is totally unsafe and I could get my system destroyed. I'm not planning on using this --- thank you for your concern. I'm just interested in understanding more about modules. (*) The problem I got myself into a mess with loading m

Re: some problems for an introductory python test

2021-08-16 Thread Hope Rouselle
Grant Edwards writes: > On 2021-08-12, Hope Rouselle wrote: > >>> OS/2 had all kinds of amazing features (for its time). [...] Plus, >>> it had this fancy concept of "extended attributes"; on older >>> systems (like MS-DOS's "FAT" fam

Re: some problems for an introductory python test

2021-08-16 Thread Hope Rouselle
Hope Rouselle writes: [...] >> Granted you may have to restrict some features if [...] > > To let students use the entire language feels a bit weird in the sense > that the group goes in so many different directions. It definitely put > teachers in a position they have to b

Re: some problems for an introductory python test

2021-08-16 Thread Hope Rouselle
Chris Angelico writes: > On Fri, Aug 13, 2021 at 2:15 AM Hope Rouselle wrote: >> >> Chris Angelico writes: >> >> > History lesson! >> > >> > Once upon a time, IBM and Microsoft looked at what Intel was >> > producing, and went, hey,

Re: some problems for an introductory python test

2021-08-16 Thread Hope Rouselle
Dennis Lee Bieber writes: > On Wed, 11 Aug 2021 09:27:38 -0300, Hope Rouselle > declaimed the following: >> >>I wouldn't. This is all Python-stuff. The course chooses a language >>like Python, but it is not trying to teach Python --- it is trying to >>

Re: some problems for an introductory python test

2021-08-16 Thread Hope Rouselle
Chris Angelico writes: > On Thu, Aug 12, 2021 at 9:23 AM Dennis Lee Bieber > wrote: [...] >> I was spoiled by the Amiga variant of REXX. Most current >> implementations (well, Regina is the only one I've looked at) can just pass >> command to the default shell. The Amiga version took

Re: some problems for an introductory python test

2021-08-16 Thread Hope Rouselle
Dennis Lee Bieber writes: > On Thu, 12 Aug 2021 06:15:28 +1000, Chris Angelico > declaimed the following: > >>The default command interpreter and shell on OS/2 was fairly primitive >>by today's standards, and was highly compatible with the MS-DOS one, >>but it also had the ability to run REXX sc

Re: some problems for an introductory python test

2021-08-12 Thread Hope Rouselle
Chris Angelico writes: [...] >> > [1] And boy oh boy was that good fun. The OS/2 Presentation Manager >> > had a wealth of power available. Good times, sad that's history now. >> >> I know OS/2 only by name. I never had the pleasure of using it. In >> fact, I don't even know how it looks. I m

Re: some problems for an introductory python test

2021-08-11 Thread Hope Rouselle
Chris Angelico writes: > On Wed, Aug 11, 2021 at 4:18 AM Hope Rouselle wrote: >> >> Chris Angelico writes: >> >> [...] >> >> >> not disagreeing... and yeah I could have thought deeper about the >> >> answer, but I still think "

Re: some problems for an introductory python test

2021-08-11 Thread Hope Rouselle
Chris Angelico writes: > On Wed, Aug 11, 2021 at 4:18 AM Hope Rouselle wrote: >> >> I totally agree with you but I didn't know that even numbers were like >> that in Python. In fact, I still don't quite believe it... >> >> >>> 2.__add_

Re: some problems for an introductory python test

2021-08-11 Thread Hope Rouselle
Greg Ewing writes: > On 11/08/21 3:22 pm, Terry Reedy wrote: >> Python is a little looser about whitespace than one might expect >> from reading 'normal' code when the result is unambiguous in that it >> cannot really mean anything other than what it does. >> >>> if3: print('yes!') >> yes! > > T

Re: some problems for an introductory python test

2021-08-11 Thread Hope Rouselle
Terry Reedy writes: > On 8/10/2021 5:27 PM, Hope Rouselle wrote: >> Terry Reedy writes: >> >>> On 8/10/2021 9:15 AM, Hope Rouselle wrote: >>>>>>> 2.__add__(3) >>>> SyntaxError: invalid syntax >>>> But then I tried: >&

Re: some problems for an introductory python test

2021-08-10 Thread Hope Rouselle
Terry Reedy writes: > On 8/10/2021 9:15 AM, Hope Rouselle wrote: >>>>> 2.__add__(3) >> SyntaxError: invalid syntax >> But then I tried: >> >>>>> (2).__add__(3) >> 5 > > Add a space is easier. >>>> 2 .__add__(3) >

Re: some problems for an introductory python test

2021-08-10 Thread Hope Rouselle
Chris Angelico writes: > On Wed, Aug 11, 2021 at 4:14 AM Hope Rouselle wrote: >> >> Chris Angelico writes: >> >> > On Tue, Aug 10, 2021 at 7:25 AM Hope Rouselle >> > wrote: >> >> I came up with the following question. Using strings of len

Re: some problems for an introductory python test

2021-08-10 Thread Hope Rouselle
Mats Wichmann writes: > On 8/9/21 3:07 PM, Hope Rouselle wrote: >> I'm looking for questions to put on a test for students who never had >> any experience with programming, but have learned to use Python's >> procedures, default arguments, if-else, strings, tu

Re: some problems for an introductory python test

2021-08-10 Thread Hope Rouselle
Chris Angelico writes: [...] >> not disagreeing... and yeah I could have thought deeper about the >> answer, but I still think "notthing has been OOP" -> "yes it has, they >> just didn't realize it" was worth mentioning > > Oh yes, absolutely agree. At the same time, inside the machine nothing

Re: some problems for an introductory python test

2021-08-10 Thread Hope Rouselle
Chris Angelico writes: > On Tue, Aug 10, 2021 at 7:25 AM Hope Rouselle wrote: >> I came up with the following question. Using strings of length 5 >> (always), write a procedure histogram(s) that consumes a string and >> produces a dictionary whose keys are each substrin

Re: on slices, negative indices, which are the equivalent procedures?

2021-08-10 Thread Hope Rouselle
Chris Angelico writes: > On Tue, Aug 10, 2021 at 7:24 AM Jack Brandom wrote: >> >> Greg Ewing writes: >> >> > On 6/08/21 12:00 pm, Jack Brandom wrote: >> >> It seems >> >> that I'd begin at position 3 (that's "k" which I save somewhere), then I >> >> subtract 1 from 3, getting 2 (that's "c", wh

some problems for an introductory python test

2021-08-09 Thread Hope Rouselle
I'm looking for questions to put on a test for students who never had any experience with programming, but have learned to use Python's procedures, default arguments, if-else, strings, tuples, lists and dictionaries. (There's no OOP at all in this course. Students don't even write ls.append(...).