And there is the ever popular recursive version you call with no while loop
in sight. And, oddly, no variable declared in your main body:
# CODE START ---
import random
def roll2():
return random.randint(1,6), random.randint(1,6)
def roll_equal(counter):
first, second = roll2()
e
On 2021-08-28 04:39, Steve wrote:
I would like to know how the data is placed on the Y-axis and at the tops of
the bars.
The data is not being shown properly. With some exceptions, it looks as if
the data is getting sorted independently from the dates.
OK, here is the code:
===
On Sun, 29 Aug 2021 at 00:04, Stefan Ram wrote:
> Stestagg writes:
> >If you're doing this analysis, I'd be pretty interested in how many of
> >those while loops where 'while True:'
>
> Here, about 40 %.
Thanks! That's an interesting stat. I might have to look more into how
while loops ar
On 28/08/2021 21:50, Hope Rouselle wrote:
>>> roll_count = 0
>>> while True:
>>> outcome = roll_two_dice()
>>> roll_count += 1
>>> if outcome[ 0 ]== outcome[ 1 ]: break
>>> return roll_count, outcome[ 0 ]
>>
>
> Wait, I'm surprised ``outcome'' is still a valid name at the
> return-sta
On 8/28/2021 8:00 AM, Hope Rouselle wrote:
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 = rol
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.
I was trying to take a look at the Python's standard libraries --- those
included in a standard installation
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 = c + 1
> x, y = roll()
> return c, (x, y)
>
> Why am I unhappy? I'm wish I cou
If you're doing this analysis, I'd be pretty interested in how many of
those while loops where 'while True:'
I'd wager 75%. But may be completely off
Steve
On Sat, 28 Aug 2021 at 23:03, Hope Rouselle wrote:
> r...@zedat.fu-berlin.de (Stefan Ram) writes:
>
> > Hope Rouselle writes:
> >>Have y
On Sun, Aug 29, 2021 at 7:40 AM Mehrzad Saremi wrote:
>
> Python currently uses name mangling for double-underscore attributes. Name
> mangling is not an ideal method to avoid name conflicting. There are
> various normal programming patterns that can simply cause name conflicting
> in double-under
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)
> rootiterable=rootpath.glob('**/*.py')
> first = True
> WhileCount =
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 rolled
>> and the final value yielded."""
>> roll_count = 0
>> wh
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 standard installation of Python 3.9.6, say --- to see
> which loops are more of
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."""
> roll_count = 0
> while True:
> outcome = roll_two_
On Sun, Aug 29, 2021 at 7:37 AM Hope Rouselle wrote:
>
> 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--
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? I had no idea. I should learn
>>some Python.
>
>
Python currently uses name mangling for double-underscore attributes. Name
mangling is not an ideal method to avoid name conflicting. There are
various normal programming patterns that can simply cause name conflicting
in double-underscore members. A typical example is when a class is
re-decorated
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
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
"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 `twothousandthreehundredandtwentythird(ls)` over
> `ls[2322]`?
19 matches
Mail list logo