Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete in Visual Basic Tasks . def factorial evens (num): Implement a function to calculate and return the product of all even numbers from

Please complete in Visual Basic image text in transcribed
Tasks . def factorial evens (num): Implement a function to calculate and return the product of all even numbers from 1 up to num (inclusive if num is even). Assumption: num will always be an integer greater than 1. Examples: o o factorial evens (4) factorial_evens (7) factorial_evens (2) #2*4 8 " . def add subtract list(xs): Accumulate the list of numbers from xs by interleaving between addition and subtraction and always start with an addition. Return the final total as a number. o Assumption: xs is a list of numbers; xs could be empty o Restriction: You can NOT call sum(). Do NOT modify the incoming list xs. o Examples: " add subtract list ([1,2,3,4,5]) " add-subtract-list((-1,2,-3,4,-51) add_subtract_list([]) +1.2+3.4+5.3 #+(-1)-2+(-3)-4+(-5)..15 # -15 . def find multiples(n,xs): Given an integer n and a list of integers xs, check and return the values from xs that are multiples of n as a list, preserving the occurrence order from xs o Assumption: n is a positive integer; xs is a list of integers; xs could be empty o Restriction: Do NOT modify the incoming list xs: build up a new list to return o Examples: find_multiples(2,[1,2,3,4,5,6])[2,4,6] find multiples (5, [5,10,5,1]) find multiples (3,[11,13]) [5,10, 5,10] #keep duplicates def last_index(xs,key): Search through the list xs for value key; return the non-negative index corresponding to the last occurrence of key. If it's not found, return None. Remember: the rightmost match should be reported when multiple matches are present. . o Assumption: xs is a list; xs could be empty o Restriction: You can NOT call.index) or.reverse) - just loop through manually and seek the key. Do NOT modify the incoming list xs o Examples: 'last index [5,1e,15,2e,25], 15)2 . last-index( [3,4,5,6,4,4,5], 4) 5 # 4 is at indexes 1,4,5 last index( [100,105,110], 234)- None

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

More Books

Students also viewed these Databases questions