Note: The maximum mark that you can received for this question depends on whether you use loops to solve the problem or
Posted: Sun May 15, 2022 1:42 pm
Need urgently will upvote please do it within 1 hour
Note: The maximum mark that you can received for this question depends on whether you use loops to solve the problem or not. If you do not use loops, you can get the maximum; otherwise, if you do use loops (either for or while), then the most you can get is 70% of the maximum. Your task is to write a Python function q5_func with the following def line: def q5_func( data , first day) : where the input data is a 1-dimensional numpy array of type int representing temperatures of consecutive days, and first day represent the day corresponding to the first value in the data array. A day is represented by an integer value from 1 to 7; 1 represents Monday, 2 represents Tuesday, and so on. Assume that first day is an integer value between 1 and 7 (inclusive). We will use the following example to illustrate what you need to do to implement the required function. Assuming that the input values are: data = [23, 26, 21, 23, 25, 26, 24, 26, 22, 21, 23, 23, 25, 26, 24, 23, 22, 23, 24, 26, 28, 27, 30, 29, 29, 27] first day = 6 The required function identifies whole weeks where temperatures increase or remain the same over the consecutive weekdays and returns the number of such weeks. The function only considers a week when temperature values for all seven days are available (day 1 to 7), otherwise, that week is ignored. The weekdays are defined as 1 to 5 (Monday to Friday). The weekend days are defined as 6 to 7 (Saturday to Sunday). O O In the example above, the first day in the data array represents Saturday (corresponding to 6). Therefore, the first whole week starts at the index 2 (value 21). The first whole week is represented by the temperature values 21, 23, 25, 26, 24, 26 and 22. The weekdays are from Monday to Friday, representing the first five values 21, 23, 25, 26 and 24. During this week's consecutive weekdays, the temperature values do not remain the same or increase, so this week is not selected. The second whole week is represented by the temperature values 21, 23, 23, 25, 26, 24 and 23. The weekdays are from Monday to Friday, representing the first five values 21, 23, 23, 25 and 26. During this week's consecutive weekdays, the temperature values remain the same or increase, so this week is selected. Similarly, the third week with weekdays 22, 23, 24, 26 and 28 is selected. The last three values are ignored because they do not represent a whole week, they only represent values for Monday to Wednesday. The function will return 2, representing two whole weeks where temperatures increase or remain the same over the consecutive weekdays. 0 0 0
Note: The maximum mark that you can received for this question depends on whether you use loops to solve the problem or not. If you do not use loops, you can get the maximum; otherwise, if you do use loops (either for or while), then the most you can get is 70% of the maximum. Your task is to write a Python function q5_func with the following def line: def q5_func( data , first day) : where the input data is a 1-dimensional numpy array of type int representing temperatures of consecutive days, and first day represent the day corresponding to the first value in the data array. A day is represented by an integer value from 1 to 7; 1 represents Monday, 2 represents Tuesday, and so on. Assume that first day is an integer value between 1 and 7 (inclusive). We will use the following example to illustrate what you need to do to implement the required function. Assuming that the input values are: data = [23, 26, 21, 23, 25, 26, 24, 26, 22, 21, 23, 23, 25, 26, 24, 23, 22, 23, 24, 26, 28, 27, 30, 29, 29, 27] first day = 6 The required function identifies whole weeks where temperatures increase or remain the same over the consecutive weekdays and returns the number of such weeks. The function only considers a week when temperature values for all seven days are available (day 1 to 7), otherwise, that week is ignored. The weekdays are defined as 1 to 5 (Monday to Friday). The weekend days are defined as 6 to 7 (Saturday to Sunday). O O In the example above, the first day in the data array represents Saturday (corresponding to 6). Therefore, the first whole week starts at the index 2 (value 21). The first whole week is represented by the temperature values 21, 23, 25, 26, 24, 26 and 22. The weekdays are from Monday to Friday, representing the first five values 21, 23, 25, 26 and 24. During this week's consecutive weekdays, the temperature values do not remain the same or increase, so this week is not selected. The second whole week is represented by the temperature values 21, 23, 23, 25, 26, 24 and 23. The weekdays are from Monday to Friday, representing the first five values 21, 23, 23, 25 and 26. During this week's consecutive weekdays, the temperature values remain the same or increase, so this week is selected. Similarly, the third week with weekdays 22, 23, 24, 26 and 28 is selected. The last three values are ignored because they do not represent a whole week, they only represent values for Monday to Wednesday. The function will return 2, representing two whole weeks where temperatures increase or remain the same over the consecutive weekdays. 0 0 0