Question: Problem 1: Rewrite the function def weekDay (month, day): from WPS2 (Problem 2). But, this time aim to make your code more concise by using

 Problem 1: Rewrite the function def weekDay (month, day): from WPS2
(Problem 2). But, this time aim to make your code more concise

Problem 1: Rewrite the function def weekDay (month, day): from WPS2 (Problem 2). But, this time aim to make your code more concise by using a list of strings that "maps" a number for a day in the week to a name. Specifically, use the following initialization early on in your function definition. dayNumbers2Names = ["Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] By making use of this list, you can replace the large if-statement that you likely have in your current definition of this function, by something quite a bit more concise. Problem 2: Write a function with the following signature def maxPairSum(L): that takes a list L of numbers as argument and returns the largest sum of a pair of consecutive numbers in the list. If the list has 0 elements or 1 element, the function should return None. Example: If L=[3,4,2,10,3,12] then all the pairs of consecutive numbers are: (3,4),(4,2),(2,10),(10,3),(3,12) and these pairs have sums 1,2,12,7, and 9 respectively. So your function should return 12 . More examples: Use these examples to test your function maxPairsum([]) maxPairSum([1.56]) maxPairSum([10,20]) 30 maxPairSum([10,2,20]) 22 maxPairSum([13,10,2,20]) 23 maxPairSum([13,5,10,2,20]) 22 maxPairSum([13,5,10,2,1,20]) 19 Complete this function The argument in can be any non-negat ive integer Bxamples a numberof Days {0} should be 0 , numberotDays(1) should be 31 , numbercfDays (2) should be 59. For any = 12 or nore, numberofbays (=1. should be 365

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!