driscollis,
@driscollis@mastodon.social avatar

Pop Quiz 🐍❓

Does the following code print True or False?

bmbufalo,
@bmbufalo@fosstodon.org avatar

@driscollis Reading that, I assumed that round would treat the .5 and round up both but when I run it in Python I get true. Why is it treating both 1.5 and 2.5 == 2? The documentation makes reference to how floats are treated differently with the round() function, is it related to that?

driscollis,
@driscollis@mastodon.social avatar

@bmbufalo No. Python uses Benker's rounding, which means it rounds to the closest even number

bmbufalo,
@bmbufalo@fosstodon.org avatar

@driscollis Interesting! Thanks!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • python
  • modclub
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • everett
  • InstantRegret
  • Youngstown
  • mdbf
  • slotface
  • rosin
  • anitta
  • kavyap
  • GTA5RPClips
  • cubers
  • JUstTest
  • osvaldo12
  • tacticalgear
  • Durango
  • khanakhh
  • ngwrru68w68
  • provamag3
  • Leos
  • tester
  • cisconetworking
  • ethstaker
  • megavids
  • normalnudes
  • lostlight
  • All magazines