IRC log of #jetrowebdev for Friday, 2024-01-05

jelknerGood day fkoikoi and tboimah!11:55
fkoikoigood morning jeff11:55
*** jelkner_ has quit (Remote host closed the connection)11:56
fkoikoitboimah and I have a question for you11:56
jelkneri'll be right back11:56
jelkneri needed to change my login method11:56
*** jelkner has quit (None)11:56
jelknerthere we go11:57
jelkneri'm back11:57
jelknergive me the question fkoikoi 11:57
jelknerquick as you can fkoikoi 11:58
fkoikoiwhy  (-2 // 4) is given the answer to be -111:58
jelknerah, good question11:58
jelknerfirst, there are two "division" operators in Python 311:59
jelkner\/ and \//11:59
jelknerhmm11:59
jelknerthey are: / and //11:59
jelknerthere we go11:59
fkoikoiwhy  (2 % -4) is given the answer to be -211:59
jelknerso / takes to numeric values (int or float) and returns a float12:00
jelknerwhile // takes to int values and returns an int12:00
jelknerare you clear on why 15 // 6 is 2, for example?12:01
fkoikoiyeh12:01
fkoikoiyeah12:01
jelknerso 2 // 4 giving 0 makes sense, right?12:01
fkoikoisure12:02
dcammueGood morning everyone12:02
jelknergreat, so the question is, why the seemingly weird behavior of -2 // 4 giving -1, right?12:02
fkoikoiyes12:02
jelknerit's called "floor division"12:03
jelknerand i just did a quick web search and found this:12:03
jelknerhttps://www.pythontutorial.net/advanced-python/python-floor-division/12:03
jelknertake a look at that and let me know if it clears things up for you12:04
jelkneryou could also ask kevin more when he comes in 2 hours if you are still confused12:04
jelknernice question!12:04
jelkneri haven't even thought about the % operator with negatives before12:05
jelknerso i need time to think about your 2nd question12:05
jelknerThe % operator produces the "modulus" (remainder)12:06
jelknerso 2 % 4 is 2 because 4 divides 2 0 times with 2 remaining12:06
jelknerthere is a cool python function called divmod that might help12:07
*** dcammue has quit (Read error: Connection reset by peer)12:07
jelknertry divmod(15, 6)12:07
jelknerwhat do you get?12:07
jelknerquickly please!12:08
fkoikoi2, 312:08
jelknergreat12:08
jelkneryou actually got (2, 3), right?12:08
fkoikoi+112:08
jelknerwhat kind of thing is that?12:09
jelknerwhat datatype?12:09
fkoikoiinteger12:09
jelknernope12:09
jelknerit's a tuple12:09
jelknerand 2-tuple with 2 ints as elements12:09
jelknerthe first element is the result of 15 // 612:10
jelknerand the second is the result of 15 % 612:10
jelknerthe "div" and the "mod"12:10
jelknerhence the name, "divmod"12:10
jelkneri have to go12:10
jelknerbut look into that more12:11
jelknerdo what kevin advised you to do12:11
jelknerwonder, explore, play12:11
jelknersee you tomorrow morning12:11
fkoikoisure12:11
jelkneri'm going to stay logged in so i can catch kevin when he arrives12:11
jelknerbut i need to prepare for class now12:12
jelknerso i'll make myself "away"12:12
*** Janet has quit (Read error: Connection reset by peer)12:29
*** tboimah has quit (Read error: Connection reset by peer)12:29
*** fkoikoi has quit (Read error: Connection reset by peer)12:29
*** tboimah has quit (Ping timeout: 480 seconds)14:04
*** Janet has quit (Ping timeout: 480 seconds)14:04
*** fkoikoi has quit (Ping timeout: 480 seconds)14:04
*** jelkner has quit (Ping timeout: 480 seconds)14:58
*** jelkner has quit (Quit: Leaving)15:58
*** shmohamud has quit (Remote host closed the connection)21:54
*** shmohamud has quit (Remote host closed the connection)21:59
*** shmohamud has quit (Remote host closed the connection)22:25
*** shmohamud has quit (Ping timeout: 480 seconds)23:11

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!