Question: create functions The post-condition of each function specifies the relationship between the function's parameters and its return value * The function must return a value

create functions  create functions The post-condition of each function specifies the relationship between
the function's parameters and its return value * The function must return
a value that makes the post-condition true for any set of data

The post-condition of each function specifies the relationship between the function's parameters and its return value * The function must return a value that makes the post-condition true for any set of data items that makes the pre-condition true You need to write code that implements each of the functions, and test that they do what their specifications say they should You are not allowed to use any external modules in the solution of these problems (NO IMPORTS) IMPORTANT Insert your Student Registration Number (SRN) between the quotation marks in the assignment statement below: SRN =n I. For example, if your SRN is 01234567 the assignment statement is should read SRN = "01234567" if should read SRN = "01234567" fififion 5 (3 marks) dief. Numberofodds (theNums) : A Pre-condition: thenums is a list of whole numbers 1. Post-condition: 1) Returns the number of odd numbers in theNums Numberotoddis ([1,2,3,4,5]) returns 3 Numberofodds ([4,18,0]) returns 0 \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# Option 6 (3 marks) \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \#\#\#\#\#\#\#\# ef Positionsofnegs (theNums) : \# Pre-condition: * theNums is a list of numbers Post-condition: Returns a list containing the positions of all of the negative numbers in theNums Examples: PositionsofNegs ([1,2,3,4,5]) returns [2,4] PositionsofNegs ([4,7,18]) returns [] PositionsofNegs ([0,3,5,9,17]) returns [1,2,3,4] return None \# Code stub: replace with function body \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \# Option 7 (3 marks) \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# def Remainders (theNums, d) : \# Pre-condition: \# theNums is a list of integers \# d is an integer * Post-condition: \# Returns a list containing the remainders obtained when dividing each of the numbers in theNums by d Examples: Remainders ([0,1,2,3],3)=[0,1,2,0] Remainders ([1,2,14,16,8],3)=[0,2,1,2] Remainders ([1,7,2,9],4)=[1,3,2,1] Remainders ([1,3,8,7],6)=[5,3,2,1] Remainders ([1,3,8,7],6)=[1,3,4,5] return None \# Code stub: replace with function body \#\#\#\#\# \#\# F \#\# \# \# \#\# Option 8 (3 marks) ef Listofsigns (theNums) : \# Pre-condition: theNums is a list of numbers Post-condition: Return value is a result list containing strings, each of which indicates the gign (positive, negative or zero) of the number at that position in theNums If the number in position i is positive, result[i] is '+' If the number in position i is negative, result [i] is ' 1 If the number in position i is zero, result [i] is 0 Example: Listofsigns ([21,9,0,6]) returns [,,,0,+] return None \# Code stub: replace with function body \# Option 9 (4 marks) def ProductofPositives (theNums) : \# Pre-condition: thenums is a list of numbers Post-condition: Return value is the product of just the positive numbers in theNums If theNums contains no positive numbers the function should return 999 - Note: the product of two numbers a and b is a times b return None \# Code stub: replace with function body

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!