Question: USE SIMPLE PYTHON LANGUAGE (do not import libraries) and share ScreenShot of pytest and code # Given two triples of numbers that represent birthdays as
USE SIMPLE PYTHON LANGUAGE (do not import libraries) and share ScreenShot of pytest and code
# Given two triples of numbers that represent birthdays as (day, month, year), return True if and only if the first one is at least as old as the second. # NB: The function should return True if both values are same. def older(a, b): pass def test_older(): assert type(older((1, 1, 1900), (1, 1, 1900))) == type(True) assert older((1, 1, 1995), (2, 1, 1995)) assert not older((2, 1, 1995), (1, 1, 1995)) assert older((1, 1, 1995), (1, 1, 1995)) assert older((31, 12, 1995), (1, 1, 1996)) assert not older((31, 4, 1995), (1, 4, 1995)) assert not older((1, 4, 1995), (31, 3, 1995)) assert not older((1, 1, 1996), (1, 1, 1995)) assert not older((1, 2, 1995), (1, 1, 1995))
# Given a list, return a list with the given lists consecutive elements grouped into tuples. # The input list is guaranteed to have an even number of elements. # Hint: You may want to use xs[i] to access elements of the list. def pairs(xs): pass def test_pairs(): assert pairs([]) == [] assert pairs([100, 200]) == [(100, 200)] assert pairs([1, 2, 3, 4]) == [(1, 2), (3, 4)] assert pairs([1, 2, 3, 4, 5, 6, 7, 8]) == [(1, 2), (3, 4), (5, 6), (7, 8)]
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
