Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Pls Create a class called Table. Please Do question 1 - 4 class Table: 1) def __init__ 2) def add_record 3) def __call__ 4)

Python Pls

Create a class called Table.

image text in transcribed

image text in transcribed

Please Do question 1 - 4

class Table:

1) def __init__

2) def add_record

3) def __call__

4) def __getitem__

Define a class named Table in a module named table.py 0. Note that the module already includes the correctly written_str_and raw methods illustrated above, which you may use for printing/debugging. You may define additional (helper) methods in this class (but not functions in the module), but you do not have to define any, I didn't. You can write your own simple code to test your class in its script, and/or use the tests in the script or the large bsc.txt file tests supplied with the project. If you want to better see the exceptions raised, and their messsages, in the bsc.txt tests, uncomment the code before the call to driver.driver(). 1. Define an _init_method that has three parameters: 1. The name of the Table (a str) 2. The fields of the Table (a list of str) 3. The checks of the Table (a list of functions or lambdas) Important: You must store this information in the attibutes named self.name, self.fields, and self.checks. Also, you must bind the attribute named self.records to an empty list. Many batch self-check tests refer to these four attribute names directly, they will fail if you do not name these attributes correctly. The original Table above could be specified (initially, without any records) by the following call. employee - Table ("Employee', 'Name','EmpId', 'DeptName'], (lambda v: type (v) is str, lambda v: type (v) is int and 1000 at Ox021C44B0>, at Ox021C48E8>] self.records - [['Bob', 'Sales'], ['Cathy', 'Finance'], ['Alice', 'Finance'], ['David', 'Sales']] Raise an AssertionError exception with a simple, appropriate message, if any of the arguments is not a field in the Table, or any argument appears more than once. Define a class named Table in a module named table.py 0. Note that the module already includes the correctly written_str_and raw methods illustrated above, which you may use for printing/debugging. You may define additional (helper) methods in this class (but not functions in the module), but you do not have to define any, I didn't. You can write your own simple code to test your class in its script, and/or use the tests in the script or the large bsc.txt file tests supplied with the project. If you want to better see the exceptions raised, and their messsages, in the bsc.txt tests, uncomment the code before the call to driver.driver(). 1. Define an _init_method that has three parameters: 1. The name of the Table (a str) 2. The fields of the Table (a list of str) 3. The checks of the Table (a list of functions or lambdas) Important: You must store this information in the attibutes named self.name, self.fields, and self.checks. Also, you must bind the attribute named self.records to an empty list. Many batch self-check tests refer to these four attribute names directly, they will fail if you do not name these attributes correctly. The original Table above could be specified (initially, without any records) by the following call. employee - Table ("Employee', 'Name','EmpId', 'DeptName'], (lambda v: type (v) is str, lambda v: type (v) is int and 1000 at Ox021C44B0>, at Ox021C48E8>] self.records - [['Bob', 'Sales'], ['Cathy', 'Finance'], ['Alice', 'Finance'], ['David', 'Sales']] Raise an AssertionError exception with a simple, appropriate message, if any of the arguments is not a field in the Table, or any argument appears more than once

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Science For Dummies

Authors: Lillian Pierson ,Jake Porway

2nd Edition

1119327636, 978-1119327639

More Books

Students also viewed these Databases questions

Question

2. What efforts are countries making to reverse the brain drain?

Answered: 1 week ago