Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
for loop stumbling block
#7
(Sep-11-2019, 08:08 AM)perfringo Wrote:
(Sep-11-2019, 07:20 AM)YoungGrassHopper Wrote: Thanks for in interesting info perfringo , now I can lecture about leap years too Cool

This knowledge is 'needed' in assignments because there are several sort of limitations (can't use built-in modules etc). 'Normal' way of doing it would be using built-in modules like calendar etc.

If it's a homework then there are (probably) automated tests which (probably) will use built-in modules which return correct leap years. So code will not pass if leap years are not calculated correctly. Professors also very often try to mislead students by providing test sample which seems general but actually is specific case (as with year 2000 in this example). That's why I called it 'critical thinking'. Been there, done that Smile

Thanks for the advice I really appreciate it perfringo. Its makes a whole lot of sense, I too think its important to maintain a critical thinking mindset.

So to get back to my piece of code , in order to make it technically sound I will need to print a phrase that states: This program will give a false positive on all centurial years which are NOT exactly devisable by 400.
Because I have no clue how to work such a fail safe into the code. My coding toolbox is vary sparse still.
I know about the "or" function but I think that only allows me to enter one condition for example:

if (years %4 == 0)or(years%400 == 0):
But then the centurial years divisible by 100 is still going to produce a false positive and I do not know to to account for that in the code apart from printing a phrase that states they(centurial years exactly divisible by 100) will produce a false positive.


Even if I could attach another "or" I am not quite sure how to state it. I think I need an "Unless" function next to the "or" LOL

Do you perhaps have a suggestion?
Reply


Messages In This Thread
for loop stumbling block - by YoungGrassHopper - Sep-10-2019, 08:38 PM
RE: for loop stumbling block - by metulburr - Sep-10-2019, 09:06 PM
RE: for loop stumbling block - by YoungGrassHopper - Sep-10-2019, 09:15 PM
RE: for loop stumbling block - by perfringo - Sep-11-2019, 05:59 AM
RE: for loop stumbling block - by YoungGrassHopper - Sep-11-2019, 07:20 AM
RE: for loop stumbling block - by perfringo - Sep-11-2019, 08:08 AM
RE: for loop stumbling block - by YoungGrassHopper - Sep-11-2019, 01:29 PM
RE: for loop stumbling block - by perfringo - Sep-11-2019, 02:45 PM
RE: for loop stumbling block - by YoungGrassHopper - Sep-11-2019, 03:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Stop/continue While loop block Moris526 68 26,956 Mar-28-2021, 09:21 PM
Last Post: Larz60+
  while loop stumbling block YoungGrassHopper 5 3,472 Sep-09-2019, 08:36 PM
Last Post: YoungGrassHopper

Forum Jump:

User Panel Messages

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