Question: USE SIMPLE PYTHON LANGUAGE (do not import libraries) and share ScreenShot of pytest and code Given a triple that represents time in 12 hour format,
USE SIMPLE PYTHON LANGUAGE (do not import libraries) and share ScreenShot of pytest and code Given a triple that represents time in 12 hour format, return a string in hh:mm format that represents time in 24 hour format. # The inputs is a triple (hh, mm, is_am) where hh and mm are numbers that represent hours and minutes and is_am is a bool that is True if and only if time is AM. def to_24(time): pass def test_to_24(): assert to_24((12, 00, True)) == "00:00" assert to_24((1, 9, True)) == "01:09" assert to_24((1, 15, True)) == "01:15" assert to_24((1, 9, False)) == "13:09" assert to_24((10, 15, True)) == "10:15" assert to_24((10, 15, False)) == "22:15" assert to_24((11, 59, False)) == "23:59"
# 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
