Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions