Question
Write a Python class definition for class Worksheet for the simple spreadsheet objects (worksheets) described below. A worksheet is a two-dimensional arrangement of cells, each
Write a Python class definition for class Worksheet for the simple spreadsheet objects (worksheets) described below. A worksheet is a two-dimensional arrangement of cells, each of which contains a simple value (string, integer or float). The columns are indexed using letters (A, B, and so on at most 26!) while the rows are indexed numerically beginning at one. Each cell has a label of the form B3 consisting of its column letter and its row number. The initializing method takes two parameters: a name for the worksheet (string) and a number (integer) representing the number of columns. Initially the worksheet contains zero rows; rows can be appended later (see below). The class definition should make the dimensions of the worksheet w accessible using w.max row and w.max column (the number of rows and columns, respectively), and should include implementations for the following methods: w.read cell(label) Return the value in the cell denoted by the string label. Ignore the possibility of there being no cell with that label. w.write cell(label, newval) Replace the value in the cell denoted by the string label with the value of parameter newval. Return the old value from that cell. Ignore the possibility of there being no cell with that label. w.append(self, newvals) Append a new row at the end of this worksheet i.e. beneath all the existing rows. Parameter newvals is a list and is optional. If newvals is provided, use its values to populate the cells of the new row left to right. If newvals is not provided, the cells in the new row are populated with the value None. w.show() Print out the contents of the worksheet. Use the example at the bottom of the page as a guide for how the output should be formatted.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started