Question: please comment each line 6. [10 Points] Programming assignment (Lab 15.8): Finding the first occurrence. This program is to be submitted both as Lab 15.8

  • please comment each line

please comment each line 6. [10 Points] Programming assignment (Lab 15.8): Finding

6. [10 Points] Programming assignment (Lab 15.8): Finding the first occurrence. This program is to be submitted both as Lab 15.8 in the zyBook and as a listing on GradeScope. You are to write the code of a Python function binsearch first (ordered_list, target) that, given a nonempty ordered list of items and a target item, all of the same type, returns the index of the first occurrence of the target in the list, if the target is in the list, and None otherwise. For example, the call binsearch first ([1, 3, 3, 7, 9], 3) should return 1 since the first 3 is at index 1. Similarly, the call binsearch first ( [1, 3, 3, 7, 9], 9) should return 4, and the call binsearch first ( [1, 3, 3, 7, 9], 5) should return None. You may not assume anything about the type of the items, other than that they are orderable. For example, items could be strings and the call binsearch first (["Alice", "Bob", "Chloe", "Chloe", "Dave"], "Chloe") should return 2. Your program will be evaluated for efficiency and style. For full credit, it may only make a single test for equality (it may only have a single "==" comparison which, additionally, may not be within any loop). That is, the only equality test happens at the end of execution, just before returning. Restrictions: Recursion is not allowed for this problem. Furthermore, you are not allowed to use any operations other than + , - , / /, x ,

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 Programming Questions!