FAQ
Hi,


A Friend is doing maths in University and has had some coursework to do with python.


The question is


"Write a program that calculates how many positive integers less than N are not divisible by 2,3 or 5. The user should be prompted to supply the Number N. Demonstrate your program output when the input N is your student id. (13006517)


"The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates.


The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list


[7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1]


Demonstrate your program output for an input value consisting of the number formed adding 10 to the last digit of your student id. (13006517)"


Any help would be appreciated

Search Discussions

  • Maxwell34m at Nov 19, 2013 at 7:05 pm

    On Tuesday, November 19, 2013 10:40:18 AM UTC-8, bradleyb... at gmail.com wrote:
    Hi,



    A Friend is doing maths in University and has had some coursework to do with python.



    The question is



    "Write a program that calculates how many positive integers less than N are not divisible by 2,3 or 5. The user should be prompted to supply the Number N. Demonstrate your program output when the input N is your student id. (13006517)



    "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates.



    The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list



    [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1]



    Demonstrate your program output for an input value consisting of the number formed adding 10 to the last digit of your student id. (13006517)"



    Any help would be appreciated

    I'm pretty sure this is not a group for helping people cheat on their school coursework.


    You,the one trying to supposedly help him couldn't even write a single line of code. How is that "helping"?


    Kindly come back when u've done some real work and you are stuck.


    I hope I've been of "help" to you and your friend.


    thanks
  • Gary Herron at Nov 19, 2013 at 7:06 pm

    On 11/19/2013 10:40 AM, bradleybooth12345 at gmail.com wrote:
    Hi,

    A Friend is doing maths in University and has had some coursework to do with python.

    The question is

    "Write a program that calculates how many positive integers less than N are not divisible by 2,3 or 5. The user should be prompted to supply the Number N. Demonstrate your program output when the input N is your student id. (13006517)

    "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates.

    The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list

    [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1]

    Demonstrate your program output for an input value consisting of the number formed adding 10 to the last digit of your student id. (13006517)"

    Any help would be appreciated

    What sort of help are you requesting? We're not in the habit of writing
    student assignments for them because they will learn nothing from such
    an effort.
    Your friend should read the book/lecture-notes/whatever, and make an
    attempt on the assignment. If he gets stuck, he may ask a specific
    Python question. I'm sure lots of help will follow.


    As a side note, these are extremely simple beginner problems, each
    requiring only a few lines of code. Any programming class that assigned
    these must have included some lectures on the basics of programming.
    That's where he should start.


    Gary Herron
  • Neil Cerutti at Nov 19, 2013 at 7:07 pm

    bradleybooth12345 at gmail.com via python.org asks:
    A Friend is doing maths in University and has had some
    coursework to do with python.

    The question is

    "Write a program that calculates how many positive integers
    less than N are not divisible by 2,3 or 5. The user should be
    prompted to supply the Number N. Demonstrate your program
    output when the input N is your student id. (13006517)

    "The collatz process is as follows. Take a positive integer n
    greater than 1. while n is greater than 1 repeat the following;
    if N is even halve it and if N is odd multiply it by 3 and add
    1. The (Unsolved) collatz conjecture is that this process
    always terminates.

    The user should be prompted to supply the number n, and your
    program should build the list of values taken by sucessive
    iteration of the algorithm, and print it out. For example, if 7
    is input your program should print the list

    [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1]

    Demonstrate your program output for an input value consisting
    of the number formed adding 10 to the last digit of your
    student id. (13006517)"

    Any help would be appreciated

    What has A Friend written so far? Where are you stuck?


    --
    Neil Cerutti

    On Tue, Nov 19, 2013 at 1:40 PM, wrote:
    Hi,

    A Friend is doing maths in University and has had some coursework to do with python.

    The question is

    "Write a program that calculates how many positive integers less than N are not divisible by 2,3 or 5. The user should be prompted to supply the Number N. Demonstrate your program output when the input N is your student id. (13006517)

    "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates.

    The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list

    [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1]

    Demonstrate your program output for an input value consisting of the number formed adding 10 to the last digit of your student id. (13006517)"

    Any help would be appreciated
    --
    https://mail.python.org/mailman/listinfo/python-list





    --
    Neil Cerutti <mr.cerutti+python@gmail.com>
  • Bradleybooth12345 at Nov 19, 2013 at 7:27 pm

    On Tuesday, November 19, 2013 6:40:18 PM UTC, bradleyb... at gmail.com wrote:
    Hi,



    A Friend is doing maths in University and has had some coursework to do with python.



    The question is



    "Write a program that calculates how many positive integers less than N are not divisible by 2,3 or 5. The user should be prompted to supply the Number N. Demonstrate your program output when the input N is your student id. (13006517)



    "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates.



    The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list



    [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1]



    Demonstrate your program output for an input value consisting of the number formed adding 10 to the last digit of your student id. (13006517)"



    Any help would be appreciated

    Think they just needed a starting point really to be honest as they can't get there head round it.


    That was all. Badly worded this, wasn't looking for someone to do it all for him apologies
  • Denis McMahon at Nov 19, 2013 at 8:48 pm

    On Tue, 19 Nov 2013 11:27:08 -0800, bradleybooth12345 wrote:


    On Tuesday, November 19, 2013 6:40:18 PM UTC, bradleyb... at gmail.com
    wrote:
    "Write a program that calculates how many positive integers less than N
    are not divisible by 2,3 or 5.
    "The collatz process .....
    Any help would be appreciated
    Think they just needed a starting point really to be honest as they
    can't get there head round it.

    First of all there seems to be two problems, not 1.


    Here are some steps for each of the calculations. Any resemblance of
    these steps to actual program code is due to my not bothering to
    obfuscate the statement and function names more than I did.


    1) Find all the numbers less than n that are not divisible by a, b, or c.


    ask the user for x;
    assign the value 0 to some other variable i;
    while i is not greater than than x do the following [
    if i is not divisible by a and i is not divisible by b and i is not
    divisible by c then display i to the user;
    add 1 to i;
    ]


    2) Find the collatz sequence for x.


    ask the user for initial x;
    while x is not 1 {
    if x is divisible by 2 [ new x = perform even number collatz math on x; ]
    otherwise [ new x = perform odd number collatz math on x; ]
    display new x to the user;
    }


    --
    Denis McMahon, denismfmcmahon at gmail.com
  • Duncan Booth at Nov 20, 2013 at 11:38 am

    Denis McMahon wrote:


    1) Find all the numbers less than n that are not divisible by a, b, or c.

    ask the user for x;
    assign the value 0 to some other variable i;
    while i is not greater than than x do the following [
    if i is not divisible by a and i is not divisible by b and i is not
    divisible by c then display i to the user;
    add 1 to i;
    ]
    The question didn't ask to find all the numbers, it asked to count how many
    there are. Also even if you change this to count instead of print, it could
    be very inefficient for large values of x.


    If x is greater than a*b*c, find how many numbers up to a*b*c are not
    divisible by a, b, or c. (Depending on your interpretation of the English
    language for 2, 3, 5 this is either 8 or 1, you could check whether the
    system is set to Australian English to determine the correct action here.)
    You may then store these numbers in a list for easy reference.


    Now the answer you want is the length of that list times the integer part
    of x divided by a*b*c plus the number of values in the list that are less
    than the remainder you get when dividing x by a*b*c.


    If x is less than a*b*c then just find how many numbers up to x are not
    divisible by a, b, or c, which would be a case of re-using some of the
    above code.


    For extra credit, calculate and use the least common multiple of a,b and c
    instead of just using their product.


    --
    Duncan Booth
  • Denis McMahon at Nov 23, 2013 at 2:03 am

    On Wed, 20 Nov 2013 11:38:14 +0000, Duncan Booth wrote:


    Denis McMahon wrote:
    1) Find all the numbers less than n that are not divisible by a, b, or
    c.
    ask the user for x;
    assign the value 0 to some other variable i;
    while i is not greater than than x do the following [
    if i is not divisible by a and i is not divisible by b and i is not
    divisible by c then display i to the user;
    add 1 to i;
    ]
    The question didn't ask to find all the numbers, it asked to count how
    many there are. ....

    My post was intended as a demonstration of how you can convert a problem
    into a sequence of steps that can then be programmed into a computer. Any
    resemblance to the posted question may have been accidental.


    --
    Denis McMahon, denismfmcmahon at gmail.com
  • Mark Janssen at Nov 19, 2013 at 10:51 pm
    Think they just needed a starting point really to be honest as they can't get there head round it.

    Then the problem is that your friend doesn't understand one or more of
    the words being used. This is s necessary prerequisite for making an
    algorithm from a text description. Perhaps they don't know what it
    means to be "divisible".


    --
    MarkJ
    Tacoma, Washington
  • Steven D'Aprano at Nov 20, 2013 at 12:17 am

    On Tue, 19 Nov 2013 10:40:18 -0800, bradleybooth12345 wrote:


    Hi,

    A Friend is doing maths in University and has had some coursework to do
    with python.

    The question is

    "Write a program that calculates how many positive integers less than N
    are not divisible by 2,3 or 5. The user should be prompted to supply the
    Number N. Demonstrate your program output when the input N is your
    student id. (13006517)



    Have your friend start by writing down how she or he would solve this
    problem by hand. I'll get you started by solving the problem for 7.


    Positive integers less than 23 are 1, 2, 3, 4, 5, 6. So let's start
    checking them for divisors:


    - 1 is not divisible by 2, 3 or 5, so we count one number.
    - 2 is divisible by 2, but not by 3 or 5, so we count two numbers.
    - 3 is not divisible by 2, so we count three numbers.
    - 4 is divisible by 2, but not 3 or 5, so we count four numbers
    - 5 is not divisible by 2, so we count five numbers.
    - 6 is divisible by 2 and 3, but not by 5, so we count six numbers.


    And the answer is: 6.


    Now that you know what you yourself would do to solve this problem, the
    next step is to write it in terms that a computer can understand. A few
    hints:


    1) You can check divisibility by using the % operator, which returns the
    remainder after division. So 36 % 6 gives 0, which means that 36 is
    divisible by 6. 37 % 6 gives 1, which means 37 is not divisible by 6.


    2) You can use "for i in range(1, N)" to generate the positive integers
    less than N.


    3) You can use the "or" operator to efficiently check multiple
    conditions. For example, this line of code:


    if (a % 2) or (a > 16):


    checks whether a number a is either an odd number or larger than sixteen,
    and if so runs the indented block of code following (not shown).


    4) You can prompt the user for a value using the input (Python 3) or
    raw_input (Python 2) function. For example, using Python 2:


    result = raw_input("Enter a number between 3 and 12: ")


    lets the user type in anything in response. That result will be a string,
    to convert it to a number:


    result = int(result)


    5) You can create a variable and initialise it to some value like this:


    count = 0


    creates a variable called "count", set to the value 0. You can then add
    one to it like this:


    count = count + 1


    or if you prefer:


    count += 1


    Either way adds one to count.


    I expect that the above should be enough to get your friend started and
    possibly even finished. If she/he gets stuck, come back with some code
    and specific questions.


    Good luck!






    --
    Steven
  • Dave Angel at Nov 20, 2013 at 3:10 am

    On 20 Nov 2013 00:17:23 GMT, Steven D'Aprano wrote:
    problem by hand. I'll get you started by solving the problem for 7.






    Positive integers less than 23 are 1, 2, 3, 4, 5, 6. So let's start
    checking them for divisors:

    Where did 23 come from?



    - 1 is not divisible by 2, 3 or 5, so we count one number.
    - 2 is divisible by 2, but not by 3 or 5, so we count two numbers.

    2 doesn't count because it's divisible by 2.

    - 3 is not divisible by 2, so we count three numbers.

    3 doesn't count because it's divisible by 3

    - 4 is divisible by 2, but not 3 or 5, so we count four numbers

    And so on.

    - 5 is not divisible by 2, so we count five numbers.
    - 6 is divisible by 2 and 3, but not by 5, so we count six numbers.



    I count 1, not 6





    And the answer is: 6.

    --
    DaveA
  • Steven D'Aprano at Nov 20, 2013 at 3:52 am

    On Tue, 19 Nov 2013 22:10:55 -0500, Dave Angel wrote:


    On 20 Nov 2013 00:17:23 GMT, Steven D'Aprano
    wrote:
    problem by hand. I'll get you started by solving the problem for 7.


    Positive integers less than 23 are 1, 2, 3, 4, 5, 6. So let's start
    checking them for divisors:
    Where did 23 come from?

    /head-desk


    Sorry, first draft of this post was going to go up to 23.





    - 1 is not divisible by 2, 3 or 5, so we count one number. - 2 is
    divisible by 2, but not by 3 or 5, so we count two numbers.
    2 doesn't count because it's divisible by 2.

    2 does count because it isn't divisible by 3. The question states,
    "[count] how many positive integers less than N are not divisible by 2,3
    or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is true,
    so two gets counted.


    The first number which is divisible by *all* of 2, 3 and 5 (i.e. fails
    the test, and therefore doesn't get counted) is 30. The next few that
    fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
    Remember, these are the numbers which should not be counted.



    I count 1, not 6

    Out of curiosity, which number did you count?






    --
    Steven
  • Dave Angel at Nov 20, 2013 at 5:54 am

    On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano wrote:
    2 does count because it isn't divisible by 3. The question states,
    "[count] how many positive integers less than N are not divisible by 2,3
    or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is true,
    so two gets counted.
    The first number which is divisible by *all* of 2, 3 and 5 (i.e. fails
    the test, and therefore doesn't get counted) is 30. The next few that
    fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
    Remember, these are the numbers which should not be counted.
    I count 1, not 6
    Out of curiosity, which number did you count?

    1 of course. It's the only one that's not divisible by any of the
    factors.


    Apparently we disagree about precedence and associativity in English.
    I believe the not applies to the result of (divisible by 2, 3, or 5),
    so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be
    49.


    If I were trying to get the series you describe, I'd phrase it as
       "Not divisible by 2, and not divisible by 3, and not divisible by 5"


    --
    DaveA
  • Alister at Nov 20, 2013 at 9:29 am

    On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:

    On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano wrote:
    2 does count because it isn't divisible by 3. The question states,
    "[count] how many positive integers less than N are not divisible by 2,3
    or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is true,
    so two gets counted.
    The first number which is divisible by *all* of 2, 3 and 5 (i.e. fails
    the test, and therefore doesn't get counted) is 30. The next few that
    fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
    Remember, these are the numbers which should not be counted.
    I count 1, not 6
    Out of curiosity, which number did you count?
    1 of course. It's the only one that's not divisible by any of the
    factors.

    Apparently we disagree about precedence and associativity in English.
    I believe the not applies to the result of (divisible by 2, 3, or 5),
    so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49.

    If I were trying to get the series you describe, I'd phrase it as
    "Not divisible by 2, and not divisible by 3, and not divisible by 5"

    This ambiguity is a great example of why teachers (and enayone else
    responsible for specifying a programming project) should take greater
    care when specifying tasks.
    if it is to late to ask for clarification (the correct step in a real
    world case) I suggest you write 2 programs 1 for each interpretation, it
    will be good for your personal learning even if the teacher does not give
    any extra credit.








    --
    I am practicing a fine point of ethics. It is acceptable to shoot back.
    It is not acceptable to shoot first.
             -- Zed Pobre
  • Alister at Nov 20, 2013 at 9:29 am

    On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:

    On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano wrote:
    2 does count because it isn't divisible by 3. The question states,
    "[count] how many positive integers less than N are not divisible by 2,3
    or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is true,
    so two gets counted.
    The first number which is divisible by *all* of 2, 3 and 5 (i.e. fails
    the test, and therefore doesn't get counted) is 30. The next few that
    fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
    Remember, these are the numbers which should not be counted.
    I count 1, not 6
    Out of curiosity, which number did you count?
    1 of course. It's the only one that's not divisible by any of the
    factors.

    Apparently we disagree about precedence and associativity in English.
    I believe the not applies to the result of (divisible by 2, 3, or 5),
    so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49.

    If I were trying to get the series you describe, I'd phrase it as
    "Not divisible by 2, and not divisible by 3, and not divisible by 5"

    This ambiguity is a great example of why teachers (and enayone else
    responsible for specifying a programming project) should take greater
    care when specifying tasks.
    if it is to late to ask for clarification (the correct step in a real
    world case) I suggest you write 2 programs 1 for each interpretation, it
    will be good for your personal learning even if the teacher does not give
    any extra credit.








    --
    I am practicing a fine point of ethics. It is acceptable to shoot back.
    It is not acceptable to shoot first.
             -- Zed Pobre
  • Mark Lawrence at Nov 20, 2013 at 1:57 pm

    On 20/11/2013 09:29, Alister wrote:
    On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:

    On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
    wrote:
    2 does count because it isn't divisible by 3. The question states,
    "[count] how many positive integers less than N are not divisible by 2,3
    or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is true,
    so two gets counted.
    The first number which is divisible by *all* of 2, 3 and 5 (i.e. fails
    the test, and therefore doesn't get counted) is 30. The next few that
    fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
    Remember, these are the numbers which should not be counted.
    I count 1, not 6
    Out of curiosity, which number did you count?
    1 of course. It's the only one that's not divisible by any of the
    factors.

    Apparently we disagree about precedence and associativity in English.
    I believe the not applies to the result of (divisible by 2, 3, or 5),
    so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49.

    If I were trying to get the series you describe, I'd phrase it as
    "Not divisible by 2, and not divisible by 3, and not divisible by 5"
    This ambiguity is a great example of why teachers (and enayone else
    responsible for specifying a programming project) should take greater
    care when specifying tasks.
    if it is to late to ask for clarification (the correct step in a real
    world case) I suggest you write 2 programs 1 for each interpretation, it
    will be good for your personal learning even if the teacher does not give
    any extra credit.

    Ambiguity is the reason that some of the most expensive language lessons
    in the world are at places like Sandhurst and West Point. Giving
    crystal clear orders, whether verbally or in writing, is considered
    quite important in the military.


    By the way, this is double posted and there were four identical messages
    from you yesterday, finger trouble or what? :)


    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer


    Mark Lawrence
  • Alister at Nov 20, 2013 at 2:49 pm

    On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:

    On 20/11/2013 09:29, Alister wrote:
    On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:

    On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
    wrote:
    2 does count because it isn't divisible by 3. The question states,
    "[count] how many positive integers less than N are not divisible by 2,3
    or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is true,
    so two gets counted.
    The first number which is divisible by *all* of 2, 3 and 5 (i.e. fails
    the test, and therefore doesn't get counted) is 30. The next few that
    fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
    Remember, these are the numbers which should not be counted.
    I count 1, not 6
    Out of curiosity, which number did you count?
    1 of course. It's the only one that's not divisible by any of the
    factors.

    Apparently we disagree about precedence and associativity in English.
    I believe the not applies to the result of (divisible by 2, 3, or 5),
    so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49.

    If I were trying to get the series you describe, I'd phrase it as
    "Not divisible by 2, and not divisible by 3, and not divisible by
    5"
    This ambiguity is a great example of why teachers (and enayone else
    responsible for specifying a programming project) should take greater
    care when specifying tasks.
    if it is to late to ask for clarification (the correct step in a real
    world case) I suggest you write 2 programs 1 for each interpretation,
    it will be good for your personal learning even if the teacher does not
    give any extra credit.
    Ambiguity is the reason that some of the most expensive language lessons
    in the world are at places like Sandhurst and West Point. Giving
    crystal clear orders, whether verbally or in writing, is considered
    quite important in the military.

    By the way, this is double posted and there were four identical messages
    from you yesterday, finger trouble or what? :)

    I don't think the problem is at my end. I am only sending once to the
    best of my knowledge
    (using Pan newsreader to Comp.lang.python)








    --
    Thou shalt not put policy into the kernel.


      - Al Viro on linux-kernel
  • Chris Angelico at Nov 20, 2013 at 3:05 pm

    On Thu, Nov 21, 2013 at 1:49 AM, Alister wrote:
    On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:
    On 20/11/2013 09:29, Alister wrote:
    On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:
    By the way, this is double posted and there were four identical messages
    from you yesterday, finger trouble or what? :)
    I don't think the problem is at my end. I am only sending once to the
    best of my knowledge
    (using Pan newsreader to Comp.lang.python)

    Exactly four again.


    https://mail.python.org/pipermail/python-list/2013-November/660769.html
    https://mail.python.org/pipermail/python-list/2013-November/660770.html
    https://mail.python.org/pipermail/python-list/2013-November/660771.html
    https://mail.python.org/pipermail/python-list/2013-November/660772.html


    Might be a problem with the mail<->news gateway, or might be that
    something's sending through by multiple routes for redundancy. The
    timestamps differ, not sure if that helps track it down.


    ChrisA
  • Alister at Nov 20, 2013 at 3:06 pm

    On Wed, 20 Nov 2013 14:49:59 +0000, Alister wrote:

    On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:
    On 20/11/2013 09:29, Alister wrote:
    On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:

    On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
    wrote:
    2 does count because it isn't divisible by 3. The question states,
    "[count] how many positive integers less than N are not divisible by 2,3
    or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is true,
    so two gets counted.
    The first number which is divisible by *all* of 2, 3 and 5 (i.e. fails
    the test, and therefore doesn't get counted) is 30. The next few that
    fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
    Remember, these are the numbers which should not be counted.
    I count 1, not 6
    Out of curiosity, which number did you count?
    1 of course. It's the only one that's not divisible by any of the
    factors.

    Apparently we disagree about precedence and associativity in English.
    I believe the not applies to the result of (divisible by 2, 3, or 5),
    so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be
    49.

    If I were trying to get the series you describe, I'd phrase it as
    "Not divisible by 2, and not divisible by 3, and not divisible by
    5"
    This ambiguity is a great example of why teachers (and enayone else
    responsible for specifying a programming project) should take greater
    care when specifying tasks.
    if it is to late to ask for clarification (the correct step in a real
    world case) I suggest you write 2 programs 1 for each interpretation,
    it will be good for your personal learning even if the teacher does
    not give any extra credit.
    Ambiguity is the reason that some of the most expensive language
    lessons in the world are at places like Sandhurst and West Point.
    Giving crystal clear orders, whether verbally or in writing, is
    considered quite important in the military.

    By the way, this is double posted and there were four identical
    messages from you yesterday, finger trouble or what? :)
    I don't think the problem is at my end. I am only sending once to the
    best of my knowledge (using Pan newsreader to Comp.lang.python)

    Ok this is now silly
    Apologies to everyone I am monitoring my network connection to confirm
    that i am not sending multiple times.








    --
    T-1's congested due to porn traffic to the news server.
  • Mark Lawrence at Nov 20, 2013 at 3:24 pm

    On 20/11/2013 15:06, Alister wrote:
    Ok this is now silly
    Apologies to everyone I am monitoring my network connection to confirm
    that i am not sending multiple times.

    Still arriving multiple times, shoot the messenger? :)


    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer


    Mark Lawrence
  • Alister at Nov 20, 2013 at 3:06 pm

    On Wed, 20 Nov 2013 14:49:59 +0000, Alister wrote:

    On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:
    On 20/11/2013 09:29, Alister wrote:
    On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:

    On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
    wrote:
    2 does count because it isn't divisible by 3. The question states,
    "[count] how many positive integers less than N are not divisible by 2,3
    or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is true,
    so two gets counted.
    The first number which is divisible by *all* of 2, 3 and 5 (i.e. fails
    the test, and therefore doesn't get counted) is 30. The next few that
    fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
    Remember, these are the numbers which should not be counted.
    I count 1, not 6
    Out of curiosity, which number did you count?
    1 of course. It's the only one that's not divisible by any of the
    factors.

    Apparently we disagree about precedence and associativity in English.
    I believe the not applies to the result of (divisible by 2, 3, or 5),
    so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be
    49.

    If I were trying to get the series you describe, I'd phrase it as
    "Not divisible by 2, and not divisible by 3, and not divisible by
    5"
    This ambiguity is a great example of why teachers (and enayone else
    responsible for specifying a programming project) should take greater
    care when specifying tasks.
    if it is to late to ask for clarification (the correct step in a real
    world case) I suggest you write 2 programs 1 for each interpretation,
    it will be good for your personal learning even if the teacher does
    not give any extra credit.
    Ambiguity is the reason that some of the most expensive language
    lessons in the world are at places like Sandhurst and West Point.
    Giving crystal clear orders, whether verbally or in writing, is
    considered quite important in the military.

    By the way, this is double posted and there were four identical
    messages from you yesterday, finger trouble or what? :)
    I don't think the problem is at my end. I am only sending once to the
    best of my knowledge (using Pan newsreader to Comp.lang.python)

    Ok this is now silly
    Apologies to everyone I am monitoring my network connection to confirm
    that i am not sending multiple times.








    --
    T-1's congested due to porn traffic to the news server.
  • Alister at Nov 20, 2013 at 3:09 pm

    On Wed, 20 Nov 2013 15:06:44 +0000, Alister wrote:

    On Wed, 20 Nov 2013 14:49:59 +0000, Alister wrote:
    On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:
    On 20/11/2013 09:29, Alister wrote:
    On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:

    On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
    wrote:
    2 does count because it isn't divisible by 3. The question states,
    "[count] how many positive integers less than N are not divisible by 2,3
    or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is true,
    so two gets counted.
    The first number which is divisible by *all* of 2, 3 and 5 (i.e. fails
    the test, and therefore doesn't get counted) is 30. The next few that
    fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
    Remember, these are the numbers which should not be counted.
    I count 1, not 6
    Out of curiosity, which number did you count?
    1 of course. It's the only one that's not divisible by any of the
    factors.

    Apparently we disagree about precedence and associativity in
    English.
    I believe the not applies to the result of (divisible by 2, 3, or
    5),
    so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be
    49.

    If I were trying to get the series you describe, I'd phrase it as
    "Not divisible by 2, and not divisible by 3, and not divisible by
    5"
    This ambiguity is a great example of why teachers (and enayone else
    responsible for specifying a programming project) should take greater
    care when specifying tasks.
    if it is to late to ask for clarification (the correct step in a real
    world case) I suggest you write 2 programs 1 for each interpretation,
    it will be good for your personal learning even if the teacher does
    not give any extra credit.
    Ambiguity is the reason that some of the most expensive language
    lessons in the world are at places like Sandhurst and West Point.
    Giving crystal clear orders, whether verbally or in writing, is
    considered quite important in the military.

    By the way, this is double posted and there were four identical
    messages from you yesterday, finger trouble or what? :)
    I don't think the problem is at my end. I am only sending once to the
    best of my knowledge (using Pan newsreader to Comp.lang.python)
    Ok this is now silly Apologies to everyone I am monitoring my network
    connection to confirm that i am not sending multiple times.

    that last one seemed good
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.
    not sure why either of them should cause the problem, I only have 1 copie
    running




    --
    Next to being shot at and missed, nothing is really quite as satisfying
    as an income tax refund.
       -- F. J. Raymond
  • Chris Angelico at Nov 20, 2013 at 3:14 pm

    On Thu, Nov 21, 2013 at 2:09 AM, Alister wrote:
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.

    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as
    a bug in Pan.


    ChrisA
  • Alister at Nov 20, 2013 at 3:34 pm

    On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:

    On Thu, Nov 21, 2013 at 2:09 AM, Alister wrote:
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.
    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as a
    bug in Pan.

    ChrisA

    As a quick test lets see how may times this one arrives






    --
    You can fool all the people all of the time if the advertising is right
    and the budget is big enough.
       -- Joseph E. Levine
  • Mark Lawrence at Nov 20, 2013 at 4:29 pm

    On 20/11/2013 15:34, Alister wrote:
    On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:

    On Thu, Nov 21, 2013 at 2:09 AM, Alister <alister.ware@ntlworld.com>
    wrote:
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.
    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as a
    bug in Pan.

    ChrisA
    As a quick test lets see how may times this one arrives

    Three. You're not Greek are you, and using a typical shabby Nazi trick
    to hide behind an ntlworld email address in order to spam us? :)


    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer


    Mark Lawrence
  • Alister at Nov 20, 2013 at 4:45 pm

    On Wed, 20 Nov 2013 16:29:54 +0000, Mark Lawrence wrote:

    On 20/11/2013 15:34, Alister wrote:
    On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:

    On Thu, Nov 21, 2013 at 2:09 AM, Alister <alister.ware@ntlworld.com>
    wrote:
    must be a strange quirk of pan & turned off hide to system tray &
    allow multiple instances.
    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as
    a bug in Pan.

    ChrisA
    As a quick test lets see how may times this one arrives
    Three. You're not Greek are you, and using a typical shabby Nazi trick
    to hide behind an ntlworld email address in order to spam us? :)

    Certainly not & I hope i never cause that much offence
    It looks like some settings in Pan cause it to misbehave.
    now it is O.K. (i think) i am going to leave it alone.








    --
       Christ was born in 4 B.C.
  • Ned Batchelder at Nov 20, 2013 at 5:12 pm

    On Wednesday, November 20, 2013 11:29:54 AM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 15:34, Alister wrote:
    On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:

    On Thu, Nov 21, 2013 at 2:09 AM, Alister <alister.ware@ntlworld.com>
    wrote:
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.
    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as a
    bug in Pan.

    ChrisA
    As a quick test lets see how may times this one arrives
    Three. You're not Greek are you, and using a typical shabby Nazi trick
    to hide behind an ntlworld email address in order to spam us? :)

    Mark Lawrence

    Nazi? Perhaps we could stick to more appropriate analogies?


    --Ned.
  • Mark Lawrence at Nov 20, 2013 at 5:37 pm

    On 20/11/2013 17:12, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 11:29:54 AM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 15:34, Alister wrote:
    On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:

    On Thu, Nov 21, 2013 at 2:09 AM, Alister <alister.ware@ntlworld.com>
    wrote:
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.
    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as a
    bug in Pan.

    ChrisA
    As a quick test lets see how may times this one arrives
    Three. You're not Greek are you, and using a typical shabby Nazi trick
    to hide behind an ntlworld email address in order to spam us? :)

    Mark Lawrence
    Nazi? Perhaps we could stick to more appropriate analogies?

    --Ned.

    It's an excellent analogy that I've used before, hence the smiley.
    Clearly you don't do any research before bothering to say anything.


    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer


    Mark Lawrence
  • Ned Batchelder at Nov 20, 2013 at 5:51 pm

    On Wednesday, November 20, 2013 12:37:31 PM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 17:12, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 11:29:54 AM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 15:34, Alister wrote:
    On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:

    On Thu, Nov 21, 2013 at 2:09 AM, Alister <alister.ware@ntlworld.com>
    wrote:
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.
    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as a
    bug in Pan.

    ChrisA
    As a quick test lets see how may times this one arrives
    Three. You're not Greek are you, and using a typical shabby Nazi trick
    to hide behind an ntlworld email address in order to spam us? :)

    Mark Lawrence
    Nazi? Perhaps we could stick to more appropriate analogies?

    --Ned.
    It's an excellent analogy that I've used before, hence the smiley.
    Clearly you don't do any research before bothering to say anything.

    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer

    Mark Lawrence

    You think these two things make an excellent analogy? 1) a newsgroup mishap being actively investigated, and 2) calculated genocide. It is not an excellent analogy, it's wildly disproportionate.


    Using a smiley doesn't fix it, and using it previously doesn't give you a free pass. What research was I supposed to have done? Examine your previous posts to see you overreacting before? That would hardly have convinced me that this was OK.


    --Ned.
  • Mark Lawrence at Nov 20, 2013 at 6:09 pm

    On 20/11/2013 17:51, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 12:37:31 PM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 17:12, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 11:29:54 AM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 15:34, Alister wrote:
    On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:

    On Thu, Nov 21, 2013 at 2:09 AM, Alister <alister.ware@ntlworld.com>
    wrote:
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.
    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as a
    bug in Pan.

    ChrisA
    As a quick test lets see how may times this one arrives
    Three. You're not Greek are you, and using a typical shabby Nazi trick
    to hide behind an ntlworld email address in order to spam us? :)

    Mark Lawrence
    Nazi? Perhaps we could stick to more appropriate analogies?

    --Ned.
    It's an excellent analogy that I've used before, hence the smiley.
    Clearly you don't do any research before bothering to say anything.

    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer

    Mark Lawrence
    You think these two things make an excellent analogy? 1) a newsgroup mishap being actively investigated, and 2) calculated genocide. It is not an excellent analogy, it's wildly disproportionate.

    Using a smiley doesn't fix it, and using it previously doesn't give you a free pass. What research was I supposed to have done? Examine your previous posts to see you overreacting before? That would hardly have convinced me that this was OK.

    --Ned.

    I suggest that you write to the BBC and get all episodes of the
    extremely popular *COMEDY* "Dad's Army" withdrawn as "typical shabby
    Nazi trick" was one of Captain Mainwearing's main lines. And if I want
    to overreact, I'll overreact, as I couldn't care two hoots whether I'm
    dealing with an arsehole from the Python Software Foundation or one
    who's not.


    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer


    Mark Lawrence
  • Antoon Pardon at Nov 21, 2013 at 11:53 am

    Op 20-11-13 19:09, Mark Lawrence schreef:
    On 20/11/2013 17:51, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 12:37:31 PM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 17:12, Ned Batchelder wrote:

    Nazi? Perhaps we could stick to more appropriate analogies?

    --Ned.
    It's an excellent analogy that I've used before, hence the smiley.
    Clearly you don't do any research before bothering to say anything.

    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer

    Mark Lawrence
    You think these two things make an excellent analogy? 1) a newsgroup
    mishap being actively investigated, and 2) calculated genocide. It is
    not an excellent analogy, it's wildly disproportionate.

    Using a smiley doesn't fix it, and using it previously doesn't give
    you a free pass. What research was I supposed to have done? Examine
    your previous posts to see you overreacting before? That would hardly
    have convinced me that this was OK.

    --Ned.
    I suggest that you write to the BBC and get all episodes of the
    extremely popular *COMEDY* "Dad's Army" withdrawn as "typical shabby
    Nazi trick" was one of Captain Mainwearing's main lines.

    Honestly? You expect people to recognize a main line from an old
    television series?

    And if I want
    to overreact, I'll overreact, as I couldn't care two hoots whether I'm
    dealing with an arsehole from the Python Software Foundation or one
    who's not.

    Now you sound just like Nikos.


    --
    Antoon Pardon
  • Chris Angelico at Nov 21, 2013 at 3:48 pm

    On Thu, Nov 21, 2013 at 10:53 PM, Antoon Pardon wrote:
    Op 20-11-13 19:09, Mark Lawrence schreef:
    I suggest that you write to the BBC and get all episodes of the
    extremely popular *COMEDY* "Dad's Army" withdrawn as "typical shabby
    Nazi trick" was one of Captain Mainwearing's main lines.
    Honestly? You expect people to recognize a main line from an old
    television series?

    Well, a good British comedy does go around a long way. I have to say,
    though, the shortness of the line makes it harder to recognize. Only
    in the tightest of circles could one say "Bother that telephone!" and
    have people understand that it's a reference to the Fat Controller
    from The Railway Series (aka the Thomas the Tank Engine books). The
    more quote you make, the more likely that pieces of it will be
    recognized.


    But as I said, all it takes is a little footnote, or something like
    "... typical shabby Nazi trick, as Capt Mainwearing would say", to
    make it clear. Most (all?) of us would understand that as a
    joke/reference and as not offensive.


    ChrisA
  • Neil Cerutti at Nov 21, 2013 at 4:29 pm

    On Thu, Nov 21, 2013 at 10:48 AM, Chris Angelico wrote:
    Well, a good British comedy does go around a long way. I have to say,
    though, the shortness of the line makes it harder to recognize. Only
    in the tightest of circles could one say "Bother that telephone!" and
    have people understand that it's a reference to the Fat Controller
    from The Railway Series (aka the Thomas the Tank Engine books). The
    more quote you make, the more likely that pieces of it will be
    recognized.

    The best sort of reference is one you can miss completely and
    still not be confused by. For example, The Borribles by De
    Larrabeiti is one of my favorite books despite my knowing virtually
    nothing of the back-streets of London or the (now dated) pop-culture
    satire it contained.


    Many of the main villains in
    the book are hilarious and mean-spirited parodies of
    a series of British children's literature, The Wombles,
    and a British TV show, Steptoe and Son, but the characters work
    fine on their own.


    But even so, I agree that a footnote is a good idea. And I haven't always
    lived up to that ideal, myself.


    --
    Neil Cerutti <mr.cerutti+python@gmail.com>
  • Chris Angelico at Nov 21, 2013 at 5:10 pm

    On Fri, Nov 22, 2013 at 3:29 AM, Neil Cerutti wrote:
    Many of the main villains in
    the book are hilarious and mean-spirited parodies of
    a series of British children's literature, The Wombles,
    and a British TV show, Steptoe and Son, but the characters work
    fine on their own.

    Yeah, that's definitely the best way to do it. You don't need to know
    The Beauty Stone to understand that Colinette, in the city of
    Lenalede, is trying to get herself appointed as Lord Chief Justice on
    the grounds that (she claims) the current incumbent is unfair in his
    rulings. But if you _do_ know that obscure 19th century opera, you'll
    know there's a line in it "And Colinette from Lenalede, who counts
    herself the fairest there". (The opera has absolutely nothing to do
    with justice, incidentally. Colinette is entering herself in a beauty
    contest. Quite a different meaning of "fairest".)


    ChrisA
  • Bradleybooth12345 at Nov 21, 2013 at 11:17 pm
    Coming back to the second question


    "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates.


    The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list


    [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1]


    We've managed to come up with this, but obviously it's wrong. Any Idea's?


    def collatz_sequence (n) :
           seq = [ ]
           if n < 1 :
              return [ ]
           while n > 1:
                if n % 2 == 0:
                 n = n/2
               else:
                  n = 3*n+ 1
               seq.append (n)
          return seq
  • Gary Herron at Nov 21, 2013 at 11:35 pm

    On 11/21/2013 03:17 PM, bradleybooth12345 at gmail.com wrote:
    Coming back to the second question

    "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates.

    The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list

    [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1]

    We've managed to come up with this, but obviously it's wrong. Any Idea's?

    def collatz_sequence (n) :
    seq = [ ]
    if n < 1 :
    return [ ]
    while n > 1:
    if n % 2 == 0:
    n = n/2
    else:
    n = 3*n+ 1
    seq.append (n)
    return seq

    Why do you say it's wrong? What does it do? What was expected?


    I see that your indentations don't match, but I can't tell if that's
    your error or an email problem. Is that the 'obviously wrong' part?


    I also see that you create an (apparently correct) function, which
    returns a nice result. But you haven't called the function to actually
    run it with a specific value to be printed out. Perhaps that's the
    'obviously wrong' part you refer to.


    However, the function itself looks correct otherwise, although you may
    want to start the sequence off with [n] rather than [] so as to match
    the suggested output.


    Gary Herron
  • Bradleybooth12345 at Nov 21, 2013 at 11:55 pm
    the problem i have is that it's just giving me the first number of the sequence not the actual sequence
  • Terry Reedy at Nov 22, 2013 at 12:55 am

    On 11/21/2013 6:55 PM, bradleybooth12345 at gmail.com wrote:
    the problem i have is that it's just giving me the first number of the sequence not the actual sequence

    Please show actually copy/pasted input and output.




    --
    Terry Jan Reedy
  • Gary Herron at Nov 22, 2013 at 4:17 am

    On 11/21/2013 03:55 PM, bradleybooth12345 at gmail.com wrote:
    the problem i have is that it's just giving me the first number of the sequence not the actual sequence

    Not when I run it. After correcting the indentation errors, I get the
    correct sequence *except* that it's missing the first number.


    You are making it very hard to help you. Please show us the *whole*
    session: the procedure (correctly indented please), the call of the
    procedure, the print that outputs the result and the actual printed
    result. Also provide an explanation of why the output is not what you
    wanted.


    Then perhaps we can get to the bottom of this.


    Gary Herron
  • Terry Reedy at Nov 22, 2013 at 12:17 am

    On 11/21/2013 6:17 PM, bradleybooth12345 at gmail.com wrote:
    Coming back to the second question

    "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates.
    The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list

    [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1]

    The specification does not say what the result should be when the input
    is 1, but given the example above, [1] seems reasonable (rather than an
    exception or []). [] is ok for 0 (or negative).

    We've managed to come up with this, but obviously it's wrong.

    In what way is it wrong? The answer to that tells you what to fix.
    A syntax error about indentation? Fix the indentation.

    Any Idea's?

    Write test code before writing the function.


    for inn,out in [(0, []), (1, [1]), (2, [2,1]),
              (3, [3,10,5,16,8,4,2,1]),
              (7, [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1]), ]:
          s = collatz(inn)
          print(inn, ':', s)
          if s != out:
              print('is not', out)

    def collatz_sequence (n) :
    seq = [ ]

    4 space indents are best; a good editor, like the one with Idle, will
    convert <tab> to 4 spaces

    if n < 1 :
    return [ ]
    while n > 1:
    if n % 2 == 0:

    dedent if so it lines up with else below

    n = n/2
    else:
    n = 3*n+ 1
    seq.append (n)
    return seq

    does not line up with while


    Once you get indents consistent, test failure should suggest the
    remaining error.


    --
    Terry Jan Reedy
  • Ned Batchelder at Nov 20, 2013 at 6:18 pm

    On Wednesday, November 20, 2013 1:09:42 PM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 17:51, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 12:37:31 PM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 17:12, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 11:29:54 AM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 15:34, Alister wrote:
    On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:

    On Thu, Nov 21, 2013 at 2:09 AM, Alister <alister.ware@ntlworld.com>
    wrote:
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.
    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as a
    bug in Pan.

    ChrisA
    As a quick test lets see how may times this one arrives
    Three. You're not Greek are you, and using a typical shabby Nazi trick
    to hide behind an ntlworld email address in order to spam us? :)

    Mark Lawrence
    Nazi? Perhaps we could stick to more appropriate analogies?

    --Ned.
    It's an excellent analogy that I've used before, hence the smiley.
    Clearly you don't do any research before bothering to say anything.

    Mark Lawrence
    You think these two things make an excellent analogy? 1) a newsgroup mishap being actively investigated, and 2) calculated genocide. It is not an excellent analogy, it's wildly disproportionate.

    Using a smiley doesn't fix it, and using it previously doesn't give you a free pass. What research was I supposed to have done? Examine your previous posts to see you overreacting before? That would hardly have convinced me that this was OK.

    --Ned.
    I suggest that you write to the BBC and get all episodes of the
    extremely popular *COMEDY* "Dad's Army" withdrawn as "typical shabby
    Nazi trick" was one of Captain Mainwearing's main lines.

    I see what you are getting at. You were referring to a TV show popular in your part of the world 30 years ago. As this is a world-wide group, you might understand that I didn't get the reference, and perhaps many others did not either. Humor is tricky, you need to know your audience.

    And if I want
    to overreact, I'll overreact, as I couldn't care two hoots whether I'm
    dealing with an arsehole from the Python Software Foundation or one
    who's not.

    I have no idea why you feel the need to insult me. As to the PSF, this is relevant: http://www.python.org/psf/codeofconduct. "Members of the community are respectful." Could you please be?


    --Ned.



    Mark Lawrence
  • Mark Lawrence at Nov 20, 2013 at 6:35 pm

    On 20/11/2013 18:18, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 1:09:42 PM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 17:51, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 12:37:31 PM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 17:12, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 11:29:54 AM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 15:34, Alister wrote:
    On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:

    On Thu, Nov 21, 2013 at 2:09 AM, Alister <alister.ware@ntlworld.com>
    wrote:
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.
    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as a
    bug in Pan.

    ChrisA
    As a quick test lets see how may times this one arrives
    Three. You're not Greek are you, and using a typical shabby Nazi trick
    to hide behind an ntlworld email address in order to spam us? :)

    Mark Lawrence
    Nazi? Perhaps we could stick to more appropriate analogies?

    --Ned.
    It's an excellent analogy that I've used before, hence the smiley.
    Clearly you don't do any research before bothering to say anything.

    Mark Lawrence
    You think these two things make an excellent analogy? 1) a newsgroup mishap being actively investigated, and 2) calculated genocide. It is not an excellent analogy, it's wildly disproportionate.

    Using a smiley doesn't fix it, and using it previously doesn't give you a free pass. What research was I supposed to have done? Examine your previous posts to see you overreacting before? That would hardly have convinced me that this was OK.

    --Ned.
    I suggest that you write to the BBC and get all episodes of the
    extremely popular *COMEDY* "Dad's Army" withdrawn as "typical shabby
    Nazi trick" was one of Captain Mainwearing's main lines.
    I see what you are getting at. You were referring to a TV show popular in your part of the world 30 years ago. As this is a world-wide group, you might understand that I didn't get the reference, and perhaps many others did not either. Humor is tricky, you need to know your audience.

    It was 45 years ago, at very much the same time that another very
    popular comedy was on, but its name escapes me right now.

    And if I want
    to overreact, I'll overreact, as I couldn't care two hoots whether I'm
    dealing with an arsehole from the Python Software Foundation or one
    who's not.
    I have no idea why you feel the need to insult me. As to the PSF, this is relevant: http://www.python.org/psf/codeofconduct. "Members of the community are respectful." Could you please be?

    --Ned.

    Mark Lawrence

    You mean after I had to plonk you from my own email because you kept
    sending messages despite the fact that I'd asked you not to. So the
    references above only apply to me but not to you? You bloody two faced
    hypocrite, excuse me while I go off and barf.


    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer


    Mark Lawrence
  • Ned Batchelder at Nov 20, 2013 at 7:54 pm

    On Wednesday, November 20, 2013 1:35:06 PM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 18:18, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 1:09:42 PM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 17:51, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 12:37:31 PM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 17:12, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 11:29:54 AM UTC-5, Mark Lawrence wrote:
    On 20/11/2013 15:34, Alister wrote:
    On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:

    On Thu, Nov 21, 2013 at 2:09 AM, Alister <alister.ware@ntlworld.com>
    wrote:
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.
    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as a
    bug in Pan.

    ChrisA
    As a quick test lets see how may times this one arrives
    Three. You're not Greek are you, and using a typical shabby Nazi trick
    to hide behind an ntlworld email address in order to spam us? :)

    Mark Lawrence
    Nazi? Perhaps we could stick to more appropriate analogies?

    --Ned.
    It's an excellent analogy that I've used before, hence the smiley.
    Clearly you don't do any research before bothering to say anything.

    Mark Lawrence
    You think these two things make an excellent analogy? 1) a newsgroup mishap being actively investigated, and 2) calculated genocide. It is not an excellent analogy, it's wildly disproportionate.

    Using a smiley doesn't fix it, and using it previously doesn't give you a free pass. What research was I supposed to have done? Examine your previous posts to see you overreacting before? That would hardly have convinced me that this was OK.

    --Ned.
    I suggest that you write to the BBC and get all episodes of the
    extremely popular *COMEDY* "Dad's Army" withdrawn as "typical shabby
    Nazi trick" was one of Captain Mainwearing's main lines.
    I see what you are getting at. You were referring to a TV show popular in your part of the world 30 years ago. As this is a world-wide group, you might understand that I didn't get the reference, and perhaps many others did not either. Humor is tricky, you need to know your audience.
    It was 45 years ago, at very much the same time that another very
    popular comedy was on, but its name escapes me right now.
    And if I want
    to overreact, I'll overreact, as I couldn't care two hoots whether I'm
    dealing with an arsehole from the Python Software Foundation or one
    who's not.
    I have no idea why you feel the need to insult me. As to the PSF, this is relevant: http://www.python.org/psf/codeofconduct. "Members of the community are respectful." Could you please be?

    --Ned.

    Mark Lawrence
    You mean after I had to plonk you from my own email because you kept
    sending messages despite the fact that I'd asked you not to. So the
    references above only apply to me but not to you? You bloody two faced
    hypocrite, excuse me while I go off and barf.

    Mark Lawrence

    I apologize for sending you off-list emails. I'm still baffled why you find them so objectionable, but I won't do it any more. I often send emails to people when I want to communicate privately with them, I didn't mean any offense.


    Next time someone doesn't understand one of your jokes, perhaps you could simply explain the joke, rather than calling them an "arsehole". Or I guess you were already angry with me, and others would have been treated better. My membership in the PSF seems to irritate you, but again, I don't know why.


    --Ned.
  • Chris Angelico at Nov 20, 2013 at 8:26 pm

    On Thu, Nov 21, 2013 at 5:18 AM, Ned Batchelder wrote:
    On Wednesday, November 20, 2013 1:09:42 PM UTC-5, Mark Lawrence wrote:
    I suggest that you write to the BBC and get all episodes of the
    extremely popular *COMEDY* "Dad's Army" withdrawn as "typical shabby
    Nazi trick" was one of Captain Mainwearing's main lines.
    I see what you are getting at. You were referring to a TV show popular in your part of the world 30 years ago. As this is a world-wide group, you might understand that I didn't get the reference, and perhaps many others did not either. Humor is tricky, you need to know your audience.

    The solution is really quite simple. The insertion of a single
    footnote will do it. Let it stand that every obscure reference is
    explained after your signature, and there you are, out of your
    difficulty at once! [1]


    ChrisA


    [1] See Gilbert & Sullivan's "Iolanthe", eg
    http://math.boisestate.edu/gas/iolanthe/web_op/iol23d.html
  • Steven D'Aprano at Nov 21, 2013 at 12:27 am
    On Wed, 20 Nov 2013 18:09:42 +0000, Mark Lawrence defended his reference
    to Nazism:

    It's an excellent analogy that I've used before, hence the smiley.
    Clearly you don't do any research before bothering to say anything.

    I for one *have* done extensive research on the Nazis, not to a
    professional academic standard, but certainly to the point where I like
    to flatter myself that I know a thing or two about them, their political
    philosophy, and their actions. I must say that your analogy "multiple
    postings to a newsgroup implies Nazi" perplexes me too.




    [...]
    I suggest that you write to the BBC and get all episodes of the
    extremely popular *COMEDY* "Dad's Army" withdrawn as "typical shabby
    Nazi trick" was one of Captain Mainwearing's main lines.

    I fully support the right of everyone to make cryptic references to
    movies, television shows, science fiction and fantasy novels, internet
    memes, and assorted pop culture references. Offler knows I've done it
    myself. But, if the reference falls flat, or worse is misunderstood, and
    sometimes they will, can I suggest there are two appropriate responses?


    1) Sheepish apology for making a reference too obscure, e.g.:


         Oh, sorry, I was quoting Captain Mainwearing's catchphrase
         from "Dad's Army", it isn't intended to imply that Alister is
         an actual goose-stepping fascist who believes a lot of racial
         pseudo-scientific rubbish.


    2) Incredulity that anyone might have missed the reference, e.g.:


        What? How can anyone not recognise that reference? Everyone I
        know in the UK over the age of 60 loves the show "Dad's Army"!
        This is one of the funniest lines from it! Oh how me dear ol'
        mum used to laugh every time Captain Mainwearing said it!


    (Listen very carefully, I shall say this only once. I'm more of a 'Ello
    'Ello person myself.)



    And if I want
    to overreact, I'll overreact, as I couldn't care two hoots whether I'm
    dealing with an arsehole from the Python Software Foundation or one
    who's not.

    This, however, is very rarely an appropriate response for anyone over the
    age of two.






    --
    Steven
  • MRAB at Nov 21, 2013 at 12:48 am

    On 21/11/2013 00:27, Steven D'Aprano wrote:
    On Wed, 20 Nov 2013 18:09:42 +0000, Mark Lawrence defended his reference
    to Nazism:
    It's an excellent analogy that I've used before, hence the smiley.
    Clearly you don't do any research before bothering to say anything.
    I for one *have* done extensive research on the Nazis, not to a
    professional academic standard, but certainly to the point where I like
    to flatter myself that I know a thing or two about them, their political
    philosophy, and their actions. I must say that your analogy "multiple
    postings to a newsgroup implies Nazi" perplexes me too.
    [snip]


    The Nazis were known for many bad things, but multiple postings wasn't
    one of them. (Nor spam, now I think about it...)
  • Tim Golden at Nov 21, 2013 at 9:08 am

    On 21/11/2013 00:27, Steven D'Aprano wrote:
    I fully support the right of everyone to make cryptic references to
    movies, television shows, science fiction and fantasy novels, internet
    memes, and assorted pop culture references.

    One of the (occasionally humbling) effects of internet communication is
    the realisation that the pop-culture reference you assumed would be
    instantly shared and understood by *any normal person anywhere* is, in
    fact, confined to your own back yard.


    You may or may not have caught sight of the BBC's recent blanket
    marketing of the upcoming 50th anniversary of Dr Who, a somewhat iconic
    British TV series. I was genuinely perplexed when US-based websites
    started running articles like "What the *** is this Dr Who all about?"
    and "All you need to know about Dr Who: a Guide for the Unknowing".


    Here in Britain, even if you've never watched and/or hate the thing, you
    can't help at least knowing *something* about Dr Who. At least the
    basics: Doctor, TARDIS, Daleks; that sort of thing.


    In reverse, I'm sometimes bemused by (often, but not always) references
    to things which apparently sit centrally in the American pop-culture
    psyche but which are unknown over here, or at least simply known *about*.


    It's not usually a problem -- it's always fun to gain a bit of an
    insight into some other culture. Just occasionally, though, someone
    says, eg, "You keep using that word; I don't think it means what you
    think it means", intending it as a humorous reference to "The Princess
    Bride". But if you have (as I strongly suspect 99% of the world's
    population has) no knowledge of that film, or at least of its
    catchphrases, then it can come across instead as a slightly blunt
    admonition of someone else's ignorance.


    (Of course, if some were to say "My name is Inigo Montoya; you killed my
    father; prepare to die" without any further comment then you'd either
    have to assume that they were making a reference to a film or book
    unknown to you or that someone going by that alias genuinely believed
    you were responsible and had tracked you down across the internet to
    confront you finally on comp.lang.python. Who knows?)


    TJG
  • Chris Angelico at Nov 21, 2013 at 9:46 am

    On Thu, Nov 21, 2013 at 8:08 PM, Tim Golden wrote:
    Of course, if some were to say "My name is Inigo Montoya; you killed my
    father; prepare to die"...

    You killfiled my address - prepare to be ignored!


    ChrisA
  • Gregory Ewing at Nov 22, 2013 at 4:10 am

    Tim Golden wrote:
    One of the (occasionally humbling) effects of internet communication is
    the realisation that the pop-culture reference you assumed would be
    instantly shared and understood by *any normal person anywhere* is, in
    fact, confined to your own back yard.

    Obviously we need a mail/newsreader plugin that googles
    for cultural references in the messages you're reading
    and inserts helpful footnote links!


    --
    Greg
  • Alister at Nov 20, 2013 at 3:34 pm

    On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:

    On Thu, Nov 21, 2013 at 2:09 AM, Alister wrote:
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.
    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as a
    bug in Pan.

    ChrisA

    As a quick test lets see how may times this one arrives






    --
    You can fool all the people all of the time if the advertising is right
    and the budget is big enough.
       -- Joseph E. Levine
  • Alister at Nov 20, 2013 at 3:35 pm

    On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:

    On Thu, Nov 21, 2013 at 2:09 AM, Alister wrote:
    must be a strange quirk of pan & turned off hide to system tray & allow
    multiple instances.
    Hmm. Hard to know, but I can imagine that having multiple instances
    MIGHT cause a problem. But if that's confirmed (maybe fire up three
    copies and then post to a test newsgroup??), I'd be reporting that as a
    bug in Pan.

    ChrisA

    As a quick test lets see how may times this one arrives






    --
    You can fool all the people all of the time if the advertising is right
    and the budget is big enough.
       -- Joseph E. Levine

Related Discussions

People

Translate

site design / logo © 2022 Grokbase