Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

minimallinux

  • 3 years ago

I cant find the definition for divisor anywhere, for this divisor = 2 for num in range(0, 10, 2):

  • This Question is Closed
  1. bwCA
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    you have defined divisor as 2 you have assigned 2 to divisor divisor in this instance is a 'variable' pointing to the integer 2 http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#other-languages-have-variables

  2. goformit100
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    POST THE QUESTION IN THE MATHEMATICS SECTION

  3. minimallinux
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Actually what I meant was 'what does divisor mean in the context of the whole loop, which finishes with print(num / divisor)

  4. bwCA
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    the shell is a great place to try things out http://dpaste.com/810583/

  5. minimallinux
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    That's what I meant, knowing that divisor is simply the number by which the original numbers are divided by, of course its obvious in retrospect !

  6. minimallinux
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Actually still not entirely sure about this one

  7. minimallinux
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Is ' num in range(0,10,2') refer to range 0 to 10 but every alternate number, then that divide by the divisor, which is 2 ?

  8. minimallinux
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Thanks

  9. rsmith6559
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    No. When range is called with three arguments, the. first is start value, the second is end value and the third is the step. num in range( 0 , 10, 2 ) will give 0, 2, 4, 6, 8

  10. minimallinux
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    So the last value is step or stride

  11. rsmith6559
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    When called with three arguments, yes.

  12. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy