Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

replace with body function Option 6 (3 marks) ######## # ###### ## # # ###### Positionsofnegs (theNums) : # Pre-condition: * theNums is a list

replace with body function
image text in transcribed
image text in transcribed
Option 6 (3 marks) \#\#\#\#\#\#\#\# \# \#\#\#\#\#\# \#\# \# \# \#\#\#\#\#\# Positionsofnegs (theNums) : \# Pre-condition: * theNums is a list of numbers \# Post-condition: \# Returns a list containing the positions of al1 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 ([12,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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions