Lab 1 – Creating a Web Page



CSCE 101 Lab 5

Turtle Control and Lists Introduction

Part A

Fun with lists (lab5_XX.py):

In this lab you will be creating a number of different functions to create and manipulate lists.

You will be using the Python IDLE (a Python editor and programming environment that comes with python). Name your file lab5_XX.py where you replace the XX with your initials.

Your program must include:

• A comment on the top line of your program containing your name.

• A comment on the second line containing your section number.

• A comment on the third line containing the date.

• A comment on the fourth line containing your email address.

• A comment with the lab number and purpose of this lab.

• Declare a function with one parameter to create a list of X elements (numbering from 1 to X) and then output this list to the screen.

• Declare a function with two parameters (X and Y) to create a list of X elements where the elements count by Y. For example, if X = 4 and Y = 3, you should create the following list [3, 6, 9, 12]. You will then need to output this list to the screen.

• Declare a function with one parameter X that creates a list of X elements (numbering from 1 to X). You will then remove the last element of the list and print the updated list repeatedly until only one element in the list remains. At this point you will output the remaining list (consisting of the one element) and a message saying that that is the last one.

• Include code in your .py file to execute each of the above three functions once each. To execute each function, you should prompt the user for whatever values the function requires, then call the function with the user's values.

• Output a message to the user thanking them from using your program that includes your first and last name.

Additional Python references:





Part B

Turtle Control (lab5_XX_turtle.py):

In this section of the lab we will be writing a program that creates a turtle and allows you to control it with the keyboard as it moves about the screen.

You will be using the Python IDLE (a Python editor and programming environment that comes with python). Name your file lab5_XX_turtle.py where you replace the XX with your initials.

Your (turtle) program must include:

• A comment on the top line of your program containing your name.

• A comment on the second line containing your section number.

• A comment on the third line containing the date.

• A comment on the fourth line containing your email address.

• A comment with the lab number and purpose of this lab.

• Don't forget to include import turtle on a line after the comments so you can use the various Turtle-related objects and methods.

• Create a turtle named after your favorite ice cream flavor. Make sure the name has no punctuation and consists only of letters, numbers and the underscore character.

• Write your python program so your turtle is constantly moving and can be turned left and right using the arrow keys on the keyboard and you can speed up or slow down your turtle using the up and down arrow keys, but the turtle can never stop moving (is not allowed to have a speed of zero).

• When you press the space bar, the turtle should move back to its starting location (0, 0) and return to its initial speed. It should also not leave a line from its original location to the center when it jumps back to start.

• Create two additional buttons to cause your turtle to do something interesting. Explain in the comments for your program exactly what the two additional buttons do.

Python Turtle Docs Reference (this is included as a general reference, you are not expected to read the entire docs on turtle):

Don’t forget to save backup copies of all your work.

To submit this lab, you will have 2 python files: Lab05_turtle_XX.py and Lab05_XX.py to be saved in your csce101 folder on your X drive before the deadline. Please note part A and part B have different deadlines.

If you have any questions or problems, please email.

DO NOT wait till the last minute to upload your files to X drive.

Academic Honesty

• The work you turn in is to be your work, not copied from someone else or from the web.

• Never allow anyone access to your files.

• Never give anyone your password.

• Never share your flash drive or email your files to anyone.

• Never give anyone a printed copy of your file or an electronic copy.

• Never allow anyone to copy your work.

General information

1. Read the entire assignment before you start.

2. We will be writing programs using Python 3. Python for both Windows and Mac is available at:



3. Download and install the latest version of Python 3.

4. As a general reminder, always maintain backup copies of your work and remember to save frequently as you are working (in case of power outage, computer locking up, etc.).

5. For this lab (and many future labs) we will be using an open source textbook, A Byte of Python available:

Online:

EPUB:

MOBI (For Kindle):

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download