Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Barb is throwing a going away party for her friends in the neighborhood. She has a lot of friends, and knows not everyone can come,
Barb is throwing a going away party for her friends in the neighborhood. She has a lot of friends, and knows not everyone can come, so she decides to write a simple program that takes a list of friends and builds a new list with every other friend (that is, friends at even indexes of the list). Assume the list of friends will be passed in this form:my_friends = ['Nancy', 'Steve', 'will', "Jim', 'Mike', 'Dustin'] Which of the following procedures will best perform this task? PROCEDURE invite_friends (my_friends) A invite_list - Il FOR EACH friend IN my_friends { APPEND (invite_list, friend) / 2 } RETURN invite_list } B PROCEDURE invite_friends (my_friends) invite_list - [] FOR EACH friend IN my_1 friends { IF (friend MOD 2 = 2) { APPEND (invite_list, friend) } RETURN invite_list PROCEDURE invite_friends (my_friends) invite_list = [] i-i REPEAT UNTIL (i > LENGTH (my_friends)) { IF (i MOD 2 = 0) { APPEND (invite_list, my_friends[i]) } it i + 1 RETURN invite_list } PROCEDURE invite_friends (my_friends) { invite_list = [] i1 REPEAT UNTIL (i > LENGTH (my_friends) ) { IF (i MOD 2 = 0) { APPEND (invite_list, friend) } i + 1 D i RETURN invite_list }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started