Question: Task 1: Basic Functions (1 mark) We often create basic functions to help distinguish areas of code that require re-use or provide helpful calculations or

 Task 1: Basic Functions (1 mark) We often create basic functions

Task 1: Basic Functions (1 mark) 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: numberOfCircles=area(lengthwidth) 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 ( ) 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=piradius2 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

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!