Menu

(Solved) : Q2 Dowt Sun Mon Tue Wed Thu Fri Sat Day Week Tuple Year 2020 Cnt 3 2020 1 1 Wednesday Let Q44087265 . . .

###################################### Q2 ############################### # dowt = (Sun, Mon, Tue, Wed, Thu, Fri,

###################################### Q2 ############################### # dowt = (‘Sun’, ‘Mon’, ‘Tue’, ‘Wed’, ‘Thu’, ‘Fri’, ‘Sat’) # day-of-week-tuple year = 2020 # cnt = 3 # 2020/1/1 is a Wednesday, so let us start a counting index of 3 for Wednesday, and keep adding one m = 3 # this will be a variable to be looped through eventually. I use the convention of 0–11 for the twelve months # month = m+1 # this is the month to be displayed/printed. The way it is set up now, it will NOT change automatically # when you change the value of m. Beware of that. # write a condition statement to determine the maxdays depending on the m value. # For example, when m=0 (Jan), maxdays should be 31, m=3 (Apr), maxdays should be 30, etc. # Try both ways, as a chunk of codes, or a one-liner maxdays = ????? print(maxdays) # Change your m value (between 0 and 11, inclusive) and run the chunk to see if prints out the correct result. # Challenge: if you can take into account that year is multiple of 4, EXCEPT when year is multiple of 100, the days # in Feb should be 29. Otherwise, there should be 28. # Examples: 2004, 2008, 2012, Feb has 29 days, but 2001, 2002, 2003, 2005, 2006, … 28 days. Year 2000 or any # century marks, multiples of 100, they are non-leap years, so only 28 days. Show transcribed image text ###################################### Q2 ############################### # dowt = (‘Sun’, ‘Mon’, ‘Tue’, ‘Wed’, ‘Thu’, ‘Fri’, ‘Sat’) # day-of-week-tuple year = 2020 # cnt = 3 # 2020/1/1 is a Wednesday, so let us start a counting index of 3 for Wednesday, and keep adding one m = 3 # this will be a variable to be looped through eventually. I use the convention of 0–11 for the twelve months # month = m+1 # this is the month to be displayed/printed. The way it is set up now, it will NOT change automatically # when you change the value of m. Beware of that. # write a condition statement to determine the maxdays depending on the m value. # For example, when m=0 (Jan), maxdays should be 31, m=3 (Apr), maxdays should be 30, etc. # Try both ways, as a chunk of codes, or a one-liner maxdays = ????? print(maxdays) # Change your m value (between 0 and 11, inclusive) and run the chunk to see if prints out the correct result. # Challenge: if you can take into account that year is multiple of 4, EXCEPT when year is multiple of 100, the days # in Feb should be 29. Otherwise, there should be 28. # Examples: 2004, 2008, 2012, Feb has 29 days, but 2001, 2002, 2003, 2005, 2006, … 28 days. Year 2000 or any # century marks, multiples of 100, they are non-leap years, so only 28 days.

Expert Answer


Answer to ###################################### Q2 ############################### # dowt = (‘Sun’, ‘Mon’, ‘Tue’, ‘Wed’, ‘Thu’, ‘…

OR