Answered step by step
Verified Expert Solution
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
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 lst[i] = a) the in and not in operators (e.g., a in lst) the list concatenation operator (e.g., lsti + lst2) 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] or lst[i : j] = t) the del statement (e.g., del lst[0]) 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 hen you locate the flava in vnur solution Exercise 1 Use the function design recipe to develop a function named count_evens. The function takes a list of integers, which may be empty. The function returns the number of even integers in the list. Common Question: Is zero odd or even? Are negative numbers odd or even? Answer: These are questions that you can answer yourself! Please do a web search using Are negative numbers odd or even. Wolfram is a reliable source
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