Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language: PYTHON Function name : favorite_day Parameters : list of tuples (dates), int (weekday, 0-6, Mondays are 0), int (day of the month 1 to

Language: PYTHON

Function name : favorite_day Parameters : list of tuples (dates), int (weekday, 0-6, Mondays are 0), int (day of the month 1 to 28) Returns: dates: list of tuples Description: Imagine that you have a favorite weekday, and want to see if certain days fall on that weekday. Using the calendar module from the Python standard library , write a function which takes in a list of tuples formatted like [(month, year), etc.], your favorite weekday, and a day of the month. Using the module, find the weekday of each (month,year) tuple at the day of the month that was passed in (1-28). If that weekday is equal to your favorite weekday, add the tuple to a list to be returned at the end of your code. Assume the day of the week will lie within 0-6 inclusive and the day of the month will be always be valid.

(Hint: look at calendar.weekday method)

Test Cases:

>>> dates = [(1, 1999), (7, 1980), (3, 2018), (12, 2003)] >>> print(favorite_day(dates, 6, 20)) [(7, 1980)]

>>> dates = [(10, 1803), (1, 2019), (6, 1964), (11, 1920), (2, 2011)] >>> print(favorite_day(dates, 0, 1)) [(6, 1964), (11, 1920)]

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

Step: 3

blur-text-image

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions

Question

Influences on Nonverbal Communication?

Answered: 1 week ago