Question: Objective To develop some functions that use loops to process lists. Learning outcomes: 4, 5, 7; Graduate attributes: 1.3, 5.3 (see the course outline) Overview

 Objective To develop some functions that use loops to process lists.Learning outcomes: 4, 5, 7; Graduate attributes: 1.3, 5.3 (see the course

Objective To develop some functions that use loops to process lists. Learning outcomes: 4, 5, 7; Graduate attributes: 1.3, 5.3 (see the course outline) Overview This lab consists of four exercises that you'll get checked by the TAS, plus two "challenge" exercises. Each solution requires no more than one loop. Your solutions can use: the [] operator to get and set list elements (e.g., lst[i] and 1st[i] = a) the in and not in operators (e.g., a in lst) the list concatenation operator (e.g., 1st1 + 1st2) the list replication operator (e.g., 1st * nor n * lst) Python's built-in len, sum, min and max functions, unless otherwise noted. Your solutions cannot use: list slicing (e.g., 1st[i : j] ord lst[i : j] = t) the del statement (e.g., del Ist[@]) Python's built-in reversed and sorted functions. any of the Python methods that provide list operations; e.g., append, clear, copy, count, extend, index, insert, pop, remove, reverse and sort list comprehensions Getting Started Begin by creating a new file within Wing 101. Save it as lab9.py Automated testing is required for this lab. (See Lab 6 for definitions of manual and automated testing). Debugging hint: If a function fails one or more tests, remember the lessons in debugging in Lab 3. Alternatively, execute the code in PythonTutor and use the memory diagrams produced by PyTutor to help you locate the flaw in your solution. Exercise 3 Use the function design recipe to develop a function named has 22. The function takes a list of integers, which may be empty. The function returns True if the list contains a 2 next to a 2. Otherwise, the function returns False . For example, when the function's argument is [1, 2, 2, 3], the function returns True. When the function's argument is [4, 2, 3, 2], the function returns False

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!