Analyze and run one of the example programs from this week's Programming Examples folder. Think about this
Fantastic news! We've Found the answer you've been seeking!
Question:
Analyze and run one of the example programs from this week's Programming Examples folder. Think about this program and your experience analyzing and running it.
answer about the following:
- what it does
- how it works
- the data structure(s) it uses
- Other insights you discovered
Transcribed Image Text:
File: arrays.py Author: Ken Lambert, copyright 2015, 2020 Used by permission. An Array is like a list, but the client can use only [], len, iter, and str. To instantiate, use <variable> = Array (<capacity>, <optional fill value>) The fill value is None by default. class Array (object): """Represents an array." # Constructor def __init__(self, capacity, fillValue = None): """Capacity is the static size of the array. fillValue is placed at each position.""" self.items list() for count in range(capacity): # Accessor methods 11111 self.items.append(fillValue) def_iter_(self): """Supports iteration over a view of an array. return iter(self.items) def_getitem_(self, index): """Subscript operator for access at index.""" return self.items [index] def _len_(self): ""> The capacity of the array. return len(self.items) nang 111111 def _str_(self): ""> The string representation of the array. return str(self.items) 111111 # Mutator methods def _setitem_(self, index, newItem): ""Subscript operator for replacement at index.""" self.items [index] = newItem File: arrays.py Author: Ken Lambert, copyright 2015, 2020 Used by permission. An Array is like a list, but the client can use only [], len, iter, and str. To instantiate, use <variable> = Array (<capacity>, <optional fill value>) The fill value is None by default. class Array (object): """Represents an array." # Constructor def __init__(self, capacity, fillValue = None): """Capacity is the static size of the array. fillValue is placed at each position.""" self.items list() for count in range(capacity): # Accessor methods 11111 self.items.append(fillValue) def_iter_(self): """Supports iteration over a view of an array. return iter(self.items) def_getitem_(self, index): """Subscript operator for access at index.""" return self.items [index] def _len_(self): ""> The capacity of the array. return len(self.items) nang 111111 def _str_(self): ""> The string representation of the array. return str(self.items) 111111 # Mutator methods def _setitem_(self, index, newItem): ""Subscript operator for replacement at index.""" self.items [index] = newItem
Expert Answer:
Answer rating: 100% (QA)
Here are detailed answers to your questions about the Array class 1 What it does The Array class is designed to represent an arraylike data structure in Python It provides methods for creating an arra... View the full answer
Related Book For
Accounting Information Systems
ISBN: 9780132871938
11th Edition
Authors: George H. Bodnar, William S. Hopwood
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Greyson Construction has the following account balances at the end of the e year. Accounts Equipment Accounts payable Salaries expense Common stock Land Notes payable Service revenue Balances $24,500...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Current Attempt in Progress Joseph Taylor recorded the following transactions during the month of April. Apr. 3 16 20 Cash Service Revenue Rent Expense Cash Salaries and Wages Expense Cash 3,020 690...
-
Under the new revenue recognition standard, what must companies do at the end of the period related to sales returns? Describe the journal entries that would be recorded.
-
Complete the following reaction for the acid hydrolysis of the disaccharide sucrose and label the two products. C12H22011 + sucrose HO water H*
-
Question: Kelly Hackworth took a leave of absence from her job at Progressive Insurance, to care for her ailing mother. When she offered to return, Progressive refused to give her the same job or one...
-
The following are selected 2014 transactions of Sean Astin Corporation. Sept. 1 Purchased inventory from Encino Company on account for $50,000. Astin records purchases gross and uses a periodic...
-
You will be employed in the finance department of Tracy Show Hire Pty Ltd in the Victoria Headquarter, and you need to complete the lodgment schedule below to ensure you meet all the businesses...
-
Susan Jones would like her investment portfolio to be selected from a combination of three stocks Alpha, Beta, and Gamma. Let variables A, B, and G denote the percentages of the portfolio devoted to...
-
7. A bank developed a model for predicting the average checking and savings account balance as balance = -17,732 + 367 age + 1,300 years education + 0.116 household wealth. a. Explain how to...
-
Two right-handed helical gears connect two shafts \(70^{\circ}\) apart. The larger gear has 50 teeth and the smaller 20. The centre distance is \(167 \mathrm{~mm}\). Determine the helix angle of the...
-
Describe the nature and components of audit risk.
-
What do you understand by movability of a mechanism?
-
Two spiral gears A and B have 45 and 15 teeth at spiral angles of \(20^{\circ}\) and \(50^{\circ}\) respectively. Both gears are of same hand. A is \(150 \mathrm{~mm}\) in diameter. Find the centre...
-
Distinguish between sampling for attributes and sampling for variables.
-
1 . In Winfield Refuse Management, Inc. Raising Debt vs Equity case, What would be the first - year additional cash outflow to bondholders in case of debt? 2 . What would be the first - year...
-
A firm offers two products for sale. The marginal cost of one product is new zero once the first unit has been produced. The marginal cost of the other product rises as output rises. What would be...
-
Hart Manufacturing Company is relatively small, with approximately 100 employees. The companys accounting server is run by two individuals. One individual is responsible for the physical operation of...
-
West Manufacturings computer division is quite large, consisting of over 200 employees. Relations among the employees within the company are quite good. Although the accounting department is a...
-
What duties should not normally be performed by the same individual in each of the following procedures? a. Bad debt write- off. b. Payroll preparation. c. Sales returns. d. Inventory purchases.
-
Taking the closing balance sheet from the example above prepare a balance sheet and profit and loss account for the third year of trading incorporating the following transactions: 1. The owner...
-
Sid's business during the next month is even better than in the first. Sid purchased a further 200 of diesel and had just filled his tank with 35 worth before finishing on the last day of the month....
-
Prepare a cash flow statement for the above business as at the end of year 2 to create the comparative figures for the above statement
Study smarter with the SolutionInn App