A201 Introduction to Programming 1

A201 Homework 8

Due Date: Tuesday, October 31, 2023.

Goal: to use lists in Python.

Make sure to complete Lab 8.1 and Lab 8.2 before doing the homework.

Create a Python script file called hw8.py. Add your name at the top as a comment, along with the class name and date.

Ex. 1. a. List Manipulation

a. Count Even Numbers

Write a function called countEven that receives a list as a parameter and returns a value representing the count of even numbers in this list. We'll assume that the list only contains integer numbers. Remember that a number k is even if k % 2 == 0.

b. Main Function

Add a function called main without any parameters. In this function, declare a list containing at least 10 integers and store it in a variable. Then call the function countEven with this list as a parameter, then print out the result with a message explaining what it is, such as "The list contains xx even numbers", where in place of "xx" you'll write the result of the function call.

Then below the function definition, add a single call to this function main.

Homework Submission

Upload the files lab8.1.py, lab8.2.py, and hw8.py in Canvas, Assignments, Homework 8.