Python Forum
Logic of using floor division and modulus for a different variable at different time
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Logic of using floor division and modulus for a different variable at different time
#2
// operator is a floor division, so it will just keep the whole number part of the result and discard decimal part.
% is modulus operator, which returns a remainder when you divide two integers. e.g. 7 % 2 -> 1 ( 7 / 2 = 3, 1 remains to 7).
Knowing this, the code is quite easy to understand. I recommend you to take pen and paper, make up a number you will use for initial "seconds" parameter, and do the calculations line by line (of course you can execute single lines in python console too).
Reply


Messages In This Thread
RE: Logic of using floor division and modulus for a different variable at different time - by j.crater - Nov-01-2018, 07:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  cmath.rect accepts a negative modulus JMB 2 365 Jan-17-2024, 08:00 PM
Last Post: JMB
  Get numpy ceil and floor value for nearest two decimals klllmmm 4 1,337 Jun-07-2023, 07:35 AM
Last Post: paul18fr
  Division questions Dionysis 5 1,101 Feb-14-2023, 02:02 PM
Last Post: Dionysis
  Floor approximation problem in algorithm gradlon93 3 994 Dec-14-2022, 07:48 PM
Last Post: Gribouillis
  Division by zero and value of argument Lawu 5 3,207 Jul-01-2022, 02:28 PM
Last Post: Lawu
  Floor division problem with plotting x-axis tick labels Mark17 5 2,157 Apr-03-2022, 01:48 PM
Last Post: Mark17
  Division calcuation with answers to 1decimal place. sik 3 2,156 Jul-15-2021, 08:15 AM
Last Post: DeaD_EyE
  Conceptualizing modulus. How to compare & communicate with values in a Dictionary Kaanyrvhok 7 4,073 Mar-15-2021, 05:43 PM
Last Post: Kaanyrvhok
Photo Locate Noise floor level for a spectral data in Python Ranjan_Pal 1 3,099 Dec-19-2020, 10:04 AM
Last Post: Larz60+
  Floor division return value Chirumer 8 3,850 Nov-26-2020, 02:34 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020