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
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 task of the assignment and the unit test are attached below. I have also linked the actual '.py' files in you need them. I'm not sure but It may involve using tuples, sets, dictionaries, lists, list comprehensions. Use those if possible. Make sure it isn't too advanced either; something that a person that's taking an intro to python course could do. Just use your better judgment please and thank you!

Link to files: https://drive.google.com/drive/folders/1zv7iLOUZsr8mwVlVTXMB5rW-Jo1FLIHk?usp=sharing?
# assign-test.py # Testing Framework for Assigment 3 # Usage: # # % python -m unittest assign-test.py 5 6 UNITTEST 8 from assign3 import flatten 10 import assign3 11 import unittest 12 13 # A subclass of unittest.TestCase 14 cLass Ass8Test (unittest.TestCase): 15 16 17 18 19 28 def test_no_nesting(self): self.assertEqual (flatten([e, 1, 2]), [e, 1, 2]) def test_flatten_integers (self) inputs [1, [2, 3, 4, 5, 6, 7], 8] expected [1, 2, 3, 4, 5, 6, 7, 8] self.assertEqual (flatten(inputs), expected) def test_two_level_nesting(self): 24 25 26 27 28 29 30 31 inputs [e, 2, [2, 3], 8, 100, 4, [50], -2] expected [e, 2, 2, 3, 8, 10e, 4, 50, -2] self.assertEqual (flatten(inputs), expected) def test_two_level_None(self): inputs [e, 2, [2, None, 3], None, 8, 100, [None], 4, [5e], 2] expected- [e, 2, 2, self.assertEqual (flatten(inputs), expected) 8, 100 4, 50, 2] def test all values are none(seLf): 35 36 37 38 39 40 41 42 43 inputs [None, [None], None, None, [None, None], None, None] expected [] self.assertEqual (flatten(inputs), expected) # Additional tests for this track def test_empty_nested_lists(self) self.assertEqual (flatten([[]]), ) def test_strings(seLf): self.assertEqual (flatten(I'e', ['1', '2']]), ['e', '1', '2']) 47 unittest.main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
