Python division

  • Comments posted to this topic are about the item Python division

  • nice question, thanks Steve
    a small error in the answer:    SQL Server Central: Question of the Day   

  • Correct answer: 

    -20

    Explanation: 

    The // operator is an integer division operator. In this case, the result of the division is converted to an integer, as the floor of the integer. That is 21 in this case.

  • correct answer = -20, yet the explanation states 21?

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    β€œlibera tute vulgaris ex”

  • If I read this  this article the result should be -21.

    Louis.

  • Tsk, tsk...


    Just because you're right doesn't mean everybody else is wrong.

  • Louis Hillebrand - Wednesday, March 14, 2018 1:13 AM

    If I read this  this article the result should be -21.

    Louis.

    +1
    Tried an online Python compiler and it also returned -21, so I guess -21 is the correct answer.

  • "The // operator is an integer division operator" that's false (-20). It's a FLOOR division (-21).
    Learn the Syntax

  • If the question had been "81 // 4" it would have been 20, but "-81 // 4" is -21...

    Can we get this point back? Petty perhaps, but still...

  • roger.plowman - Wednesday, March 14, 2018 6:32 AM

    If the question had been "81 // 4" it would have been 20, but "-81 // 4" is -21...

    Can we get this point back? Petty perhaps, but still...

    You got more points by typing a response than the question is worth.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • All replies agreed that the correct answer should be -21 (because one of the operands is negative). In this case, can we get our point back for today's breakfast? πŸ™‚

  • MariusJarzebowski - Wednesday, March 14, 2018 7:23 AM

    All replies agreed that the correct answer should be -21 (because one of the operands is negative). In this case, can we get our point back for today's breakfast? πŸ™‚

    You did by posting. Honestly, points are rather....well...pointless. They are also super easy to earn. Just start answering forum questions.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Carlo Romagnano - Wednesday, March 14, 2018 2:21 AM

    "The // operator is an integer division operator" that's false (-20). It's a FLOOR division (-21).
    Learn the Syntax

    That's what I found too (just a different post)

  • Sean Lange - Wednesday, March 14, 2018 8:55 AM

    MariusJarzebowski - Wednesday, March 14, 2018 7:23 AM

    All replies agreed that the correct answer should be -21 (because one of the operands is negative). In this case, can we get our point back for today's breakfast? πŸ™‚

    You did by posting. Honestly, points are rather....well...pointless. They are also super easy to earn. Just start answering forum questions.

    So that's why I can never seem to find a place to "spend" them πŸ˜›

  • Verified online at python.org. Answer was -21.

  • Hate to see the (red x) Incorrect  for my answer when I know I got it right.

  • Viewing 15 posts - 1 through 15 (of 22 total)

    You must be logged in to reply to this topic. Login to reply