Hello, I’m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9 as the answer. Thanks
var = 0
for i in range(3):
for j in range(-2,-7,-2):
var += 1
print(var)
Sent from my iPhone
Hello, I’m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9 as the answer. Thanks
var = 0
for i in range(3):
for j in range(-2,-7,-2):
var += 1
print(var)
... print(j)for j in range(-2, -7, -2):
this looks to me like it might be a piece of homework, as it would be
given by teachers or professors.
This list has got the rule, that members do not solve other's
homework. Because very often homework is meant to sit down and think
about it.
BTW, there is an indentation error in your original post - line 5 should
line up with line 4.
Hello, I’m new to learning python and I stumbled upon a question nested loops.
BTW, there is an indentation error in your original post - line 5
should line up with line 4.
As a Python beginner, I find that Python is annoyingly picky about
indents. And, the significance of indents is a bit of a minefield for beginners.
For example, in the above code, the indent of the final line very significantly affects the results:
print(var)
print(var)
print(var)
These are all different.
On 05/08/2022 08:56, Frank Millman wrote:
BTW, there is an indentation error in your original post - line 5
should line up with line 4.
As a Python beginner, I find that Python is annoyingly picky about
indents. And, the significance of indents is a bit of a minefield for beginners.
For example, in the above code, the indent of the final line very significantly affects the results:
print(var)
print(var)
print(var)
These are all different.
Hello, I’m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9 as the answer. Thanks
var = 0
for i in range(3):
for j in range(-2,-7,-2):
var += 1
print(var)
I wonder if someone is pulling our leg as they are sending from an invalid email address of "GB <NOTsomeone@microsoft.invalid>" which is a bit sick.
I have trouble imagining ANYONE learning a language like python without rapidly being told that python uses indentation instead of various ways to detect when a body of text is considered a single composite item.
And code like their example is also nonsense:
print(var)
print(var)
print(var)
On 05/08/2022 08:56, Frank Millman wrote:
BTW, there is an indentation error in your original post - line 5 should line up with line 4.
As a Python beginner, I find that Python is annoyingly picky about
indents. And, the significance of indents is a bit of a minefield for beginners.
On Fri, Aug 5, 2022 at 12:35 AM <ojomooluwatolami675@gmail.com> wrote:...
Of if you don't have (or want) a debugger, you could change it to:
var = 0
for i in range(3):
print('i is', i)
for j in range(-2,-7,-2):
print('j is', j)
var += 1
print(var)
And note that 3 times 3 is 9.
BTW, there is an indentation error in your original post - line 5
should line up with line 4.
I wonder if someone is pulling our leg as they are sending from anbit sick.
invalid email address of "GB <NOTsomeone@microsoft.invalid>" which is a
I have trouble imagining ANYONE learning a language like pythoncomposite item.
without rapidly being told that python uses indentation instead of
various ways to detect when a body of text is considered a single
And code like their example is also nonsense:
print(var)
print(var)
print(var)
Hello, I’m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9
as the answer. Thanks
var = 0 for i in range(3):
for j in range(-2,-7,-2):
var += 1
print(var)
Sent from my iPhone
As a Python beginner, I find that Python is annoyingly picky about
indents. And, the significance of indents is a bit of a minefield for beginners.
In C, this doesn't do what it looks like it's supposed to do.
if (foo)
do_this();
and_this();
then_do_this();
On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards <grant.b.edwards@gmail.com> wrote:
In C, this doesn't do what it looks like it's supposed to do.
if (foo)
do_this();
and_this();
then_do_this();
It's been quite a while since I used C, but with the right compiler
flag(s), I think this may be a thing of the past when compiling with gcc: https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-indentation-vs-goto-fail
On Sat, 6 Aug 2022 at 13:54, Dan Stromberg <drsalists@gmail.com> wrote:
On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards <grant.b.edwards@gmail.com>Ah yes, because compiler warnings are always viewed and acted upon.
wrote:
In C, this doesn't do what it looks like it's supposed to do.It's been quite a while since I used C, but with the right compiler
if (foo)
do_this();
and_this();
then_do_this();
flag(s), I think this may be a thing of the past when compiling with gcc:
https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-indentation-vs-goto-fail
Have you ever watched the compilation of a large open-source project,
done using the project's own build system and therefore the team's
preferred warning settings? It's normal to have such a spew of
warnings that you can't find anything interesting, or to have new
warnings in new versions of GCC be utterly useless for the same
reason.
ChrisA
On 8/6/22 12:01 AM, Chris Angelico wrote:
On Sat, 6 Aug 2022 at 13:54, Dan Stromberg <drsalists@gmail.com> wrote:
On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards <grant.b.edwards@gmail.com> >> wrote:Ah yes, because compiler warnings are always viewed and acted upon.
In C, this doesn't do what it looks like it's supposed to do.It's been quite a while since I used C, but with the right compiler
if (foo)
do_this();
and_this();
then_do_this();
flag(s), I think this may be a thing of the past when compiling with gcc: >> https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-indentation-vs-goto-fail
Have you ever watched the compilation of a large open-source project,
done using the project's own build system and therefore the team's preferred warning settings? It's normal to have such a spew of
warnings that you can't find anything interesting, or to have new
warnings in new versions of GCC be utterly useless for the same
reason.
ChrisA
You make it so you HAVE to fix the warning by adding the option to make warnings into errors.
This does mean that you need to fix all the warnings that don't actually
mean anything,
Good code shouldn't generate many warnings, either you have warnings
enabled that you don't care about, or your code is doing things you have
told the complier you shouldn't do.
On 8/6/22 8:12 AM, Chris Angelico wrote:
On Sat, 6 Aug 2022 at 22:08, Richard Damon <Richard@damon-family.org> wrote:
On 8/6/22 12:01 AM, Chris Angelico wrote:I say again: have you ever watched the compilation of a large
On Sat, 6 Aug 2022 at 13:54, Dan Stromberg <drsalists@gmail.com> wrote: >>>> On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards <grant.b.edwards@gmail.com>You make it so you HAVE to fix the warning by adding the option to make
wrote:Ah yes, because compiler warnings are always viewed and acted upon.
In C, this doesn't do what it looks like it's supposed to do.It's been quite a while since I used C, but with the right compiler
if (foo)
do_this();
and_this();
then_do_this();
flag(s), I think this may be a thing of the past when compiling with gcc:
https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-indentation-vs-goto-fail
Have you ever watched the compilation of a large open-source project,
done using the project's own build system and therefore the team's
preferred warning settings? It's normal to have such a spew of
warnings that you can't find anything interesting, or to have new
warnings in new versions of GCC be utterly useless for the same
reason.
ChrisA
warnings into errors.
This does mean that you need to fix all the warnings that don't actually >> mean anything,
Good code shouldn't generate many warnings, either you have warnings
enabled that you don't care about, or your code is doing things you have >> told the complier you shouldn't do.
open-source project? You cannot turn warnings into errors, because
there are ALWAYS warnings. Maybe, once upon a time, the policy was to ensure that there were no warnings on any major compiler; but times
change, compilers add new warnings, new compilers join the club, and
it becomes practically impossible to prevent warnings. Which, in turn, makes all warnings basically meaningless.
Hmm. I don't think I've ever compiled gcc from source. Maybe I should
do that, just to see whether gcc itself compiles with no warnings
under gcc.
ChrisA
And for any project, that is a choice THEY made.
On Sat, 6 Aug 2022 at 22:08, Richard Damon <Richard@damon-family.org> wrote:
On 8/6/22 12:01 AM, Chris Angelico wrote:I say again: have you ever watched the compilation of a large
On Sat, 6 Aug 2022 at 13:54, Dan Stromberg <drsalists@gmail.com> wrote: >>>> On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards <grant.b.edwards@gmail.com> >>>> wrote:You make it so you HAVE to fix the warning by adding the option to make
Ah yes, because compiler warnings are always viewed and acted upon.
In C, this doesn't do what it looks like it's supposed to do.It's been quite a while since I used C, but with the right compiler
if (foo)
do_this();
and_this();
then_do_this();
flag(s), I think this may be a thing of the past when compiling with gcc: >>>> https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-indentation-vs-goto-fail
Have you ever watched the compilation of a large open-source project,
done using the project's own build system and therefore the team's
preferred warning settings? It's normal to have such a spew of
warnings that you can't find anything interesting, or to have new
warnings in new versions of GCC be utterly useless for the same
reason.
ChrisA
warnings into errors.
This does mean that you need to fix all the warnings that don't actually
mean anything,
Good code shouldn't generate many warnings, either you have warnings
enabled that you don't care about, or your code is doing things you have
told the complier you shouldn't do.
open-source project? You cannot turn warnings into errors, because
there are ALWAYS warnings. Maybe, once upon a time, the policy was to
ensure that there were no warnings on any major compiler; but times
change, compilers add new warnings, new compilers join the club, and
it becomes practically impossible to prevent warnings. Which, in turn,
makes all warnings basically meaningless.
Hmm. I don't think I've ever compiled gcc from source. Maybe I should
do that, just to see whether gcc itself compiles with no warnings
under gcc.
ChrisA
On 8/6/22 12:01 AM, Chris Angelico wrote:gcc:
On Sat, 6 Aug 2022 at 13:54, Dan Stromberg <drsalists@gmail.com> wrote:
On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards
<grant.b.edwards@gmail.com>
wrote:
In C, this doesn't do what it looks like it's supposed to do.It's been quite a while since I used C, but with the right compiler
if (foo)
do_this();
and_this();
then_do_this();
flag(s), I think this may be a thing of the past when compiling with
https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-indAh yes, because compiler warnings are always viewed and acted upon.
entation-vs-goto-fail
Have you ever watched the compilation of a large open-source
project, done using the project's own build system and therefore the
team's preferred warning settings? It's normal to have such a spew
of warnings that you can't find anything interesting, or to have new warnings in new versions of GCC be utterly useless for the same
reason.
ChrisA
You make it so you HAVE to fix the warning by adding the option to
make warnings into errors.
This does mean that you need to fix all the warnings that don't
actually mean anything,
Good code shouldn't generate many warnings, either you have warnings
enabled that you don't care about, or your code is doing things you
have told the complier you shouldn't do.
For future, more complex, questions of this kind,
you might have a look at the module `pdb` in Python's runtime library.
It implements a debugger which allows you (among other features)
to interactively run a program line by line
and explore the state of all involved variables.
_
|1x
|1y
|[['*'], [' ...screen
On 06/08/2022 11.41, avi.e.gross@gmail.com wrote:
I wonder if someone is pulling our leg as they are sending from an
invalid email address of "GB <NOTsomeone@microsoft.invalid>" which is
a bit sick.
There are a number of folk who use evidently false email addresses - the
OP's had me amused.
Such 'hiding' is a matter for the List-Admins (thanks for all the work exerted on our behalf!) and how it fits with the Code-of-Conduct.
dn wrote:
On 06/08/2022 11.41, avi.e.gross@gmail.com wrote:
I wonder if someone is pulling our leg as they are sending from an
invalid email address of "GB <NOTsomeone@microsoft.invalid>" which is
a bit sick.
There are a number of folk who use evidently false email addresses - the
OP's had me amused.
Such 'hiding' is a matter for the List-Admins (thanks for all the work
exerted on our behalf!) and how it fits with the Code-of-Conduct.
Invalid sending addresses (email@somewhere.invalid) are a standard
practice in Usenet, to combat bots scraping posts for email addresses (remember, Usenet predates basically all spam prevention tech).
As there is a gateway between the mailing lists and Usenet, I *imagine*
that the use of said invalid addresses are within the rules -- I mean,
if they weren't, the maintainers wouldn't keep the two lists
connected.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 236:27:56 |
Calls: | 6,624 |
Files: | 12,172 |
Messages: | 5,319,829 |