Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
code help
#10
(Jun-13-2019, 03:13 PM)jefsummers Wrote: Note that the non-homework assignment though requires use of a data structure for the months and the use of subroutines.

Guilty as charged (almost). Smile There is no subroutine but I believe that list of days in month qualifies as 'data structure'. Yes, it doesn't have name and will cease to exist but definitely list comprehension creates list. Naming it would have taken fun out of it. And of course - one can define function and return whole thing - this way there will be subroutine as well

# datastructure which holds days of months :-)
[[31, 30][i <= 6 and i % 2 == 0 or i > 7 and i % 2 != 0] if i != 2 else [28, 29][year % 4 == 0 and year % 100 != 0 or year % 400 == 0] for i in range(1 ,13)]
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
code help - by callanlove - Jun-13-2019, 09:41 AM
RE: code help - by perfringo - Jun-13-2019, 10:38 AM
RE: code help - by callanlove - Jun-13-2019, 10:45 AM
RE: code help - by perfringo - Jun-13-2019, 10:51 AM
RE: code help - by kotter - Jun-13-2019, 11:47 AM
RE: code help - by buran - Jun-13-2019, 12:32 PM
RE: code help - by jefsummers - Jun-13-2019, 01:26 PM
RE: code help - by perfringo - Jun-13-2019, 02:05 PM
RE: code help - by jefsummers - Jun-13-2019, 03:13 PM
RE: code help - by perfringo - Jun-13-2019, 04:15 PM

Forum Jump:

User Panel Messages

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