# ASSUMED PYTHON VERSION IS 3.11
# TESTS WRITTEN TO BE EXECUTED FROM https://[Log in to view URL]
import unittest
import time
import sys

def timed(func):
    def wrap(*args, **kwargs):
        tic = time.perf_counter()
        result = func(*args, **kwargs)
        toc = time.perf_counter()
        print(f"{sys._getframe(1).f_code.co_name} took {toc - tic:0.9f} seconds")
        return result
    return wrap

class TestDemo(unittest.TestCase):
    def test_say_greeting_returns_hello_when_greeting_number_is_1(self):
        self.assertEqual('hello', say_greeting(1))
        
    def test_say_greeting_returns_hi_when_greeting_number_is_not_1(self):
        self.assertEqual('hi', say_greeting(0))

@timed
def say_greeting(greeting_number: int):
## DO NOT ALTER CODE ABOVE THIS LINE ##################################
    """ YOUR TASK:
    Given an integer, return the string 'hello' if the integer
    is 1, otherwise return the string 'hi'.

    Example 1:
    Input: greeting_number = 1
    Output: 'hello'

    Example 2:
    Input: greeting_number = 0
    Output: 'hi'
    """
    # if greeting_number == 1:
    #     return 'hello'
    # else:
    #     return 'hi'
    pass # YOUR CODE GOES HERE

## DEBUG CODE HERE ####################################################
# print(say_greeting(1))
# print(say_greeting(1231))

## TEST EXECUTION. COMMENT/UNCOMMENT ##################################
unittest.main(TestDemo(), verbosity=2)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: