Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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

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

Database Systems On GPUs In Databases

Authors: Johns Paul ,Shengliang Lu ,Bingsheng He

1st Edition

1680838482, 978-1680838480

More Books

Students also viewed these Databases questions

Question

Explain the nature of human resource management.

Answered: 1 week ago

Question

Write a note on Quality circles.

Answered: 1 week ago