We often create basic functions to help distinguish areas of code that require re-use or provide...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
We often create basic functions to help distinguish areas of code that require re-use or provide helpful calculations or manipulation of variables. Steps 1. Create a new file and name it appropriately. (Remember to include .py otherwise VSCode will not interpret it as a python file) 2. Write a function called circlesInRectangle which takes three parameters: length, width (of a rectangle) and area (of a circle). 3. This function should return the number of circles that can fit into a rectangle. 4. Operations performed by this function should be consistent with the following formula: number of Circles = (length x width) area Task 2: Basic Functions Cont. (1 mark) Steps 1. Write a function named areaOfCircle which takes one parameter: radius (of a circle). 2. This function should return the area. Note: You will need to utilise Pi (r) which is included in the "math" package. It is poor coding practice to import entire packages. You should only import what you need. 3. At the beginning of your Python file, insert the code below to allow access to the value. from math import pi 4. Operations performed by this function should be consistent with the following formula: area = pi x radius² Task 3: Calling Functions (1 mark) Calling a function within another function is common practice in programming. You can create smaller, more manageable functions to be utilised within other areas of your code. Steps 1. Modify the function "circlesInRectangle" to make use of the function "areaOfCircle". Note: Make a copy of your current method to show your supervisor at the end of class. You can comment it out so that the IDE does not show an error. 2. You will need to change the area parameter to radius. 3. When calling your formula in code, replace area with your method and pass it the radius. We often create basic functions to help distinguish areas of code that require re-use or provide helpful calculations or manipulation of variables. Steps 1. Create a new file and name it appropriately. (Remember to include .py otherwise VSCode will not interpret it as a python file) 2. Write a function called circlesInRectangle which takes three parameters: length, width (of a rectangle) and area (of a circle). 3. This function should return the number of circles that can fit into a rectangle. 4. Operations performed by this function should be consistent with the following formula: number of Circles = (length x width) area Task 2: Basic Functions Cont. (1 mark) Steps 1. Write a function named areaOfCircle which takes one parameter: radius (of a circle). 2. This function should return the area. Note: You will need to utilise Pi (r) which is included in the "math" package. It is poor coding practice to import entire packages. You should only import what you need. 3. At the beginning of your Python file, insert the code below to allow access to the value. from math import pi 4. Operations performed by this function should be consistent with the following formula: area = pi x radius² Task 3: Calling Functions (1 mark) Calling a function within another function is common practice in programming. You can create smaller, more manageable functions to be utilised within other areas of your code. Steps 1. Modify the function "circlesInRectangle" to make use of the function "areaOfCircle". Note: Make a copy of your current method to show your supervisor at the end of class. You can comment it out so that the IDE does not show an error. 2. You will need to change the area parameter to radius. 3. When calling your formula in code, replace area with your method and pass it the radius.
Expert Answer:
Answer rating: 100% (QA)
Task 1 I have created a new file called basicfunctionspy and written ... 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
-
Consider the graph below for the market of eyeglasses. If there is a price floor at $9, calculate the consumer surplus, producer surplus, and dead weight loss. The y- intercept for supply is 0, and...
-
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...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
A W. Hopes year ended on 30 June 2011. Write up the ledger accounts, showing the transfers to the financial statements and the balances carried down to the next year for the following: (a)...
-
Find the inverse Laplace transform f (t) if F(s) is F(s) = se-s / (s + 1) (s + 2)
-
During 2017, Laiken Limited sold its only Class 3 asset. At the time of sale, the balance of the undepreciated capital cost for this class was $37,450. The asset originally cost $129,500....
-
Air expands adiabatically through a turbine from a pressure and temperature of \(180 \mathrm{psia}, 1600{ }^{\circ} \mathrm{R}\) to a pressure of \(14.7 \mathrm{psia}\). If the actual temperature...
-
Ryan Company wishes to prepare a forecasted income statement, balance sheet, and statement of cash flows for 2012. Ryans balance sheet and income statement for 2011 follow: Balance Sheet 2011 Cash ....
-
Skuta Pty Ltd Scenario The scenario provides you with a brief overview of a hypothetical company, 'Skuta' and a contemporary scenario. Be aware that the scenario may not cover every detail that you...
-
Regulators, in protecting the public interest, are examining Wincox Insurance Company's financial statements. These regulators impose requirements on Wincox's financial statements because of which...
-
Bundling does not always help the monopolist. To see this, suppose that Comcast provides both phone and internet service to two types of custumers, with valuations Phone $30 Sa Internet $16 $24...
-
Do a little reading on LVM expansion. We chose to extend our virtual disk in our hypervisor to provision additional space to expand our LVM volume. What if that volume was on a physical disk and was...
-
Each year, the IRS audits a large number of individual income tax returns in the hopes of collecting additional revenue for the federal government and encouraging all income tax filers to honestly...
-
The factorial of a nonnegative integer n is written n! (pronounced "n factorial") and is defined as follows: n! = n (n-1) (n-2) * * 2 1 (for n >= 1) and n! = 1 (if n == 0). For example, 5! 5*4*3*2*1,...
-
Do hospitals benefit from discharging patients early before they are fully recover? Can you share an example of when you or someone you know was treated or hospitalized by a healthcare provider but...
-
Review the Appendix to Chapter 1 "Measuring Economic Activity, Prices, and the Inflation Rate" in Money, Banking, and Financial Markets , especially the section "The GDP Deflator and the Inflation...
-
Mason, George's friend, recently gave him a terrific stock idea. George opted to take out a $20,000 loan to make the stock purchase possible because he didn't have any cash on hand to invest. The...
-
Bobbie Singh provides writing services for small businesses. He blogs for companies that need professionally written content. His business records at November 15, 2023, are shown below: During the...
-
Match the following list of items to the letters A through F in Figure. 1. Create Order. 2. Master Price List. 3. Customer Order. 4. Order Database. 5. Sales Order. 6. EnterOrder. Order Entry
-
The Morgan Department Store has approximately 1,000 customer accounts. Each month a special clerk opens the mail and prepares a remittance list of all monies received on account. The checks are then...
-
Match the following list of seven items to the letters A through G in Figure. 1. Purchase Database 2. Purchase Order 3. Prepare Order 4. Vendor 5. Purchase Requisition 6. Select Vendor 7. Order...
-
If a product is produced in high volume by a few large organizations, what phase of the product life cycle is it most likely in?
-
Is a highly standardized product usually produced through a make-to-order or a make-to-stock processing strategy?
-
Does providing customized products generally involve less capital investment or less skilled labor, when compared to more standardized products?
Phylogeny Of The Primates A Multidisciplinary Approach 1975th Edition - ISBN: 1468421689 - Free Book
Study smarter with the SolutionInn App