HW 6

Download and save the file hw06c.py to your CS100/hw folder.

This file is a template. It contains some code there for you. Put your name at the top of the file. There are 10 questions total, each worth 1 point. The questions are written in comments. Each question involves you implementing a function below it to solve a specific problem.

Note that questions 5-10 involve you implementing a python function that works like one of the list methods already provided by Python. Although Python provides this functionality, it is good practice and instructive to consider how it is implemented. DO NOT simply call the equivalent function – write your own implementation. This includes functions for

I suggest you work one question at a time. Read the question description and write your solution. Before you move on, test that your solution is correct by uncommenting all lines of code which call the function at the bottom of the program.

When you have questions about the homework, please join office hours for either of the zone interns.

Expected output

Check your work. If it doesn’t match, look at the function call and your function implementation to see what’s going on. You can also use the debugger to help you step through the function.

Q1 - testA: [7, 'a', 'cat', 7, False, 9, 'word', 3]
Q1 - testB: ['e', 'c', 'cat', 'bird', 'd', 42, 'word', 3]
----------------------
Q2 - testA: ['fun', 'with', 'python', 'programming']
Q2 - testB: ['if', 'you', 'like', 'this', 'class', 'you', 'might', 'like', 'CS110', 'too']
----------------------
Q3 - testA: [1, 1, 2, 3, 5]
Q3 - testB: [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
----------------------
Q4 - testA: 4
Q4 - testB: -1
----------------------
Q5 - testA: 1
Q5 - testB: -5
----------------------
Q6 - testA: [1, 2, 3, 5, 8, 9, 10, 15, 23, 42, 104]
Q6 - testB: [-5, 1, 3, 8, 9, 10, 15, 23, 42]
----------------------
Q7 - testA: True
Q7 - testB: False

Grading

You will be graded based on the quality of your code and that the output of each function matches the expected result. I will be checking to see that you correctly computed the solution programmatically.

In order to receive any credit, your program must run without syntax errors in Thonny.

How to submit

Double check that your program runs without syntax errors. Submit the file hw06.py updated with your changes to Moodle.