Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE CODE USING PYTHON 3! (PLEASE ANSWER ASAP) : Be sure to write clear commen

ID: 3918786 • Letter: P

Question

PLEASE CODE USING PYTHON 3! (PLEASE ANSWER ASAP) :

Be sure to write clear comments throughout when coding this and make sure the code passes the unit test. Both images of the task and the unit test are attached below. This requires you to create a function that's a generator. So this should use "yields". Make sure it isn't too advanced either; something that a person that's taking an intro to python course could do. Make it as simple as possible basically. Just use your better judgment please and thank you!

Unittest: def test next_ tues_1(self): gennext tues (2, 23) nxt next (gen) self.assertEqual(nxt, (3, 2))

Explanation / Answer

def next_tues(month,day):
    l = [31,28,31,30,31,30,31,31,30,31,30,31]
    d = day
    mon = month
    while True:
        d = d + 7
        if d > l[mon-1]:
            d = d - l[mon-1]
            mon = mon + 1
            if mon > 12:
                mon = 1
        t = (mon,d)
        yield t

gen = next_tues(7,25)
for i in range(35):
    print(next(gen))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote