Question: Please use python to solve this Activities X Google Chrome 21 Ama 18:32 Downloads/ EC 201-all-2020-2021-qul X ECC201 2020 2021 Fall. * Consider The Following

 Please use python to solve this Activities X Google Chrome 21Ama 18:32 Downloads/ EC 201-all-2020-2021-qul X ECC201 2020 2021 Fall. * ConsiderThe Following Fix M Search results-abdulmur * + O localhost:8888otebooks/Downloads/ecc201-fall-2020-2021-quiz07.ipynb jupyter ecc201-fall-2020-2021-quiz07(anced) Logout File View Insert CI Kemal Widgets Help Not Trusted Python3 O + 8 Mark + + N Hun 5 6 7

Please use python to solve this

Activities X Google Chrome 21 Ama 18:32 Downloads/ EC 201-all-2020-2021-qul X ECC201 2020 2021 Fall. * Consider The Following Fix M Search results-abdulmur * + O localhost:8888otebooks/Downloads/ecc201-fall-2020-2021-quiz07.ipynb jupyter ecc201-fall-2020-2021-quiz07 (anced) Logout File View Insert CI Kemal Widgets Help Not Trusted Python 3 O + 8 Mark + + N Hun 5 6 7 8 9 Writing data 4.dat ? Now consider the following ADT named triangular . triangular data filepath, data converter-str ) initializes a triangular object with the data provided in a lile al data_filepath Each row of data will be stored as a list of values converted to the data format that will be specified by the data converter parameter, which must be a function that takes single parameter. The default value of data converter function is str. That is the data converter will be called on each piece of data to do the conversion The data will be stored as a list of sublists in an instance wariable called data. If the inpur data is not triangular, the initializer method should raise a ValueError For example, the content of data 1.dat should be represented as Il'l'] ('2', '31. ['4', '5', '6']. ['7', '8', '9', 'A'. ('B', 'C', 'D', 'E', 'F'). ['G', 'H', 'I', '', 'K', 'L']] in memory len triangular ... )) should retum the number of rows in the data. In data 1.dat, there are 6 rows, for example, triangular.check() should return True if the inpur data specified for the initializer above is indeed triangular in shape. . a + b should retum the addion of two triangular objects, a and b. depending on their type. Assume that a and b will always be compatible If the dimensions of a and b are not identical, this method should raise an AssertionError. Implement this ADT in Python PROVIDE YOUR ANSWER IN THE FOLLOWING CODE CELL In (): 1 + YOUR CODE HERE 2 raise NotImplementedError) In [ 1 : WARNING! Activities X Logout Google Chrome 21 Ama 18:32 Downloads/ EC 201-all-2020-2021-qul X ECC201 2020-2021 | Fall: x * Consider The Following * M Search results-abdulmur * + O localhost:8888otebooks/Downloads/ecc201-fall-2020-2021-quiz07.ipynb jupyter ecc201-fall-2020-2021-quiz07 (and) File View Kemel Widgets Help + N Run C Marco BISMI Implement this ADT in Python. PROVIDE YOUR ANSWER IN THE FOLLOWING CODE CELL Edt Call Not Trusted Python 30 WWII In [ ]: 1 YOUR CODE MERE 2 raise Not InplententedError) In 1 ? WARNING 52 6. If you have not defined an instance field named 'data' in your triangular class, all remaining tests will fail! 9. Please follow the provided specifications! 10 11 12 13 t = triangular 'dala 1.dat' 14 15 data' in dir( t.data) 16 17 assert hasattrit, 'data' ). "Your triangular instance should have a 'data field as specified In 1: it = triangular 'data_1.dat' assert t.check() = True 5 t.data In [ ]: 1 try: 2 triangular data 2.dat') 4 except ValueError: print("Got ValueErrar as expected!" } pass 7 8 else: assert False 10 In [ ]: la = triangular 'data 1.dat' c = triangular data 3.dat') 4 print a.data print/ c.data) Activities X Google Chrome 21 Ama 18:34 Downloads/ EC 201-all-2020-2021-qul X ECC201 2020 2021 Fall. x Consider The Following Fx M Search results-abdulmur x + O localhost:8080otebooks/Downloads/ecc201-Fall-2020-2021-quiz07.ipynb jupyter ecc201-fall-2020-2021-quiz07 (anced) File Edit View Insert Cell Kemal Widgets Help + + + N Run Markdown Logout Not Trust Python 3 In 1: 1 a = triangular 'data 1. dat:) c = triangulari data 3.dat'i 4 printr o data) 5 print/ c.data) 6 7 student answer = a + c 8 correct answer = \ 9 Il'la 10 ['20', '3'1. 11 ['d', 'e', 'of' 12 ['79', 'Bh', '91', 'Ajl. 13 ['k', 'l', 'd', 'en', 'Fo'l. ['G', 'H' 'ir', 's', 'K', 'Lu'll 15 16 #print/ student_answer ) 17 18 assert student answer -- correct answer 19 ? In [ ]: 1 Using ord') as the data converter function 27 3 a = triangular data 1.dat', ord) 4 d = triangular 'data 4.dat', ord) 5 adata = a.data[:41 7 d.data = d.dataf: 41 9 print ( a.data) te print (d.data) 11 12 student answer ad 13 14 print/ student answer ) 15 16 correct answer = [197], 199, 101], [103, 105, 107] [109, 111, 113, 1221] 18 sprint/ student_answer 19 2e assert studenil_answer == correct answer 21 In (): 1 a. triangulart 'data 1.dat', ord) 2d - triangular 'data_4.dat', ord) 4 print a.data) 5 print/ d.data) 7try: Activities X Google Chrome 21 Ama 18:34 Downloads/ EC 201-all-2020-2021-qul X ECC201 2020 2021 Fall. x Consider The Following Fx M Search results-abdulmur x + O localhost:8888otebooks/Downloads/ecc201-fall-2020-2021-quiz07.ipynb jupyter ecc201-fall-2020-2021-quiz07 (anGamed) File Edit View cal Kemal Widget Help Logout Not Trusted Python 3 N kun IC Markdown In : ? 1 Using ord') as the data converter function 2 3 a = triangular 'data 1.dat', ord) 4 d = triangular 'data 4.dat', ord) 5 6 a.data = a.data[:41 d.data = d.data[:41 9 print(a.data) 10 print (d.data 11 12 student answer = atd 13 14 Aprinti student answer ) 15 16 correct answer - [197], 199, 101], [103, 105, 107]. (109, 111, 113, 122]] 17 18 print/ student answer ) 19 20 assert student answer == correct answer 21 In (): la triangular 'data 1.dat', ard) 2d - triangular 'data 4.dat', ard) 3 4 Aprint/ a.data) 5 print/ d.data) 6 7try: 10 except AssertionError: 11 print( 'Got AssertionError as expected) 12 pass 13 14 else: 15 assert False 16 END OF TEST Activities X Google Chrome 21 Ama 18:32 Downloads/ EC 201-all-2020-2021-qul X ECC201 2020 2021 Fall. * Consider The Following Fix M Search results-abdulmur * + O localhost:8888otebooks/Downloads/ecc201-fall-2020-2021-quiz07.ipynb jupyter ecc201-fall-2020-2021-quiz07 (anced) Logout File View Insert CI Kemal Widgets Help Not Trusted Python 3 O + 8 Mark + + N Hun 5 6 7 8 9 Writing data 4.dat ? Now consider the following ADT named triangular . triangular data filepath, data converter-str ) initializes a triangular object with the data provided in a lile al data_filepath Each row of data will be stored as a list of values converted to the data format that will be specified by the data converter parameter, which must be a function that takes single parameter. The default value of data converter function is str. That is the data converter will be called on each piece of data to do the conversion The data will be stored as a list of sublists in an instance wariable called data. If the inpur data is not triangular, the initializer method should raise a ValueError For example, the content of data 1.dat should be represented as Il'l'] ('2', '31. ['4', '5', '6']. ['7', '8', '9', 'A'. ('B', 'C', 'D', 'E', 'F'). ['G', 'H', 'I', '', 'K', 'L']] in memory len triangular ... )) should retum the number of rows in the data. In data 1.dat, there are 6 rows, for example, triangular.check() should return True if the inpur data specified for the initializer above is indeed triangular in shape. . a + b should retum the addion of two triangular objects, a and b. depending on their type. Assume that a and b will always be compatible If the dimensions of a and b are not identical, this method should raise an AssertionError. Implement this ADT in Python PROVIDE YOUR ANSWER IN THE FOLLOWING CODE CELL In (): 1 + YOUR CODE HERE 2 raise NotImplementedError) In [ 1 : WARNING! Activities X Logout Google Chrome 21 Ama 18:32 Downloads/ EC 201-all-2020-2021-qul X ECC201 2020-2021 | Fall: x * Consider The Following * M Search results-abdulmur * + O localhost:8888otebooks/Downloads/ecc201-fall-2020-2021-quiz07.ipynb jupyter ecc201-fall-2020-2021-quiz07 (and) File View Kemel Widgets Help + N Run C Marco BISMI Implement this ADT in Python. PROVIDE YOUR ANSWER IN THE FOLLOWING CODE CELL Edt Call Not Trusted Python 30 WWII In [ ]: 1 YOUR CODE MERE 2 raise Not InplententedError) In 1 ? WARNING 52 6. If you have not defined an instance field named 'data' in your triangular class, all remaining tests will fail! 9. Please follow the provided specifications! 10 11 12 13 t = triangular 'dala 1.dat' 14 15 data' in dir( t.data) 16 17 assert hasattrit, 'data' ). "Your triangular instance should have a 'data field as specified In 1: it = triangular 'data_1.dat' assert t.check() = True 5 t.data In [ ]: 1 try: 2 triangular data 2.dat') 4 except ValueError: print("Got ValueErrar as expected!" } pass 7 8 else: assert False 10 In [ ]: la = triangular 'data 1.dat' c = triangular data 3.dat') 4 print a.data print/ c.data) Activities X Google Chrome 21 Ama 18:34 Downloads/ EC 201-all-2020-2021-qul X ECC201 2020 2021 Fall. x Consider The Following Fx M Search results-abdulmur x + O localhost:8080otebooks/Downloads/ecc201-Fall-2020-2021-quiz07.ipynb jupyter ecc201-fall-2020-2021-quiz07 (anced) File Edit View Insert Cell Kemal Widgets Help + + + N Run Markdown Logout Not Trust Python 3 In 1: 1 a = triangular 'data 1. dat:) c = triangulari data 3.dat'i 4 printr o data) 5 print/ c.data) 6 7 student answer = a + c 8 correct answer = \ 9 Il'la 10 ['20', '3'1. 11 ['d', 'e', 'of' 12 ['79', 'Bh', '91', 'Ajl. 13 ['k', 'l', 'd', 'en', 'Fo'l. ['G', 'H' 'ir', 's', 'K', 'Lu'll 15 16 #print/ student_answer ) 17 18 assert student answer -- correct answer 19 ? In [ ]: 1 Using ord') as the data converter function 27 3 a = triangular data 1.dat', ord) 4 d = triangular 'data 4.dat', ord) 5 adata = a.data[:41 7 d.data = d.dataf: 41 9 print ( a.data) te print (d.data) 11 12 student answer ad 13 14 print/ student answer ) 15 16 correct answer = [197], 199, 101], [103, 105, 107] [109, 111, 113, 1221] 18 sprint/ student_answer 19 2e assert studenil_answer == correct answer 21 In (): 1 a. triangulart 'data 1.dat', ord) 2d - triangular 'data_4.dat', ord) 4 print a.data) 5 print/ d.data) 7try: Activities X Google Chrome 21 Ama 18:34 Downloads/ EC 201-all-2020-2021-qul X ECC201 2020 2021 Fall. x Consider The Following Fx M Search results-abdulmur x + O localhost:8888otebooks/Downloads/ecc201-fall-2020-2021-quiz07.ipynb jupyter ecc201-fall-2020-2021-quiz07 (anGamed) File Edit View cal Kemal Widget Help Logout Not Trusted Python 3 N kun IC Markdown In : ? 1 Using ord') as the data converter function 2 3 a = triangular 'data 1.dat', ord) 4 d = triangular 'data 4.dat', ord) 5 6 a.data = a.data[:41 d.data = d.data[:41 9 print(a.data) 10 print (d.data 11 12 student answer = atd 13 14 Aprinti student answer ) 15 16 correct answer - [197], 199, 101], [103, 105, 107]. (109, 111, 113, 122]] 17 18 print/ student answer ) 19 20 assert student answer == correct answer 21 In (): la triangular 'data 1.dat', ard) 2d - triangular 'data 4.dat', ard) 3 4 Aprint/ a.data) 5 print/ d.data) 6 7try: 10 except AssertionError: 11 print( 'Got AssertionError as expected) 12 pass 13 14 else: 15 assert False 16 END OF TEST

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!