Python代写:CS177-Python-Programming-Lab-Prep6

代写Python基础练习题,练习Python的基础使用方法,属于比较基础的Python作业。
Python

Lab Prep 6

Due Date:
This assignment is due before 11:59 pm on the night before your lab meeting

Assignment Description:

In this assignment you will write and submit the labprep6.py program. Complete and submit the file by 11:59pm on the night before your lab to receive full credit.

Python Graphics Library:
Carefully review the Graphics chapter in the Zelle text (Ch 4) covering this topic and the Python Graphics
library documentation found at: http://mcsp.wartburg.edu/zelle/python/graphics/graphics.pdf before starting Lab Prep 6. If you haven’t already, download the Graphics module graphics.py from Blackboard. Remember that it must be in the same folder as labprep6.py

Steps For This Assignment:

  1. Setup your Python file labprep6.py with an appropriate comments header
  2. Organize labprep6.py using comments for each block of planned code
  3. In each block, write the necessary Python code to complete the task
  4. Save, test, then upload your completed labprep6.py Python program to Blackboard

TO DO #1: Setup Your Python Program File labprep 6 .py
In Python, the # sign indicates a comment, which documents and organizes your code. Python does not

1
2
3
execute these commented lines; they are used to make the program easier to understand. In the Python IDLE
editor, open a new program window. At the top of the file, create a program header by typing in the following
text:

TO DO #2: Organize labprep6.py with pseudo code comments

Plan and comment your program. By now, you should have had enough
practice to writing good, descriptive pseudo code comments for each
section and function.

TO DO #3: The main() Function

Write a Python main() function that takes no arguments and returns no

values. This function should create a Graphics Window, of size 5 00x 500
pixels. Set the background to light grey. Create a red Square ( Rectangle
with equal sides measuring 30) in the center of the Graphics Window.
An example is shown in Figure 1.

Figure 1 : Graphics window with red Square

1
2
3
4
5
# CS 177 – labprep6.py
# {insert your name, and Purdue ID here}
# Following Coding Standards and Guidelines
# {insert a description of the program here}
#

TO DO #4: Animating the square’s movement
Edit your main() function, so that it now waits for the user to click anywhere within the Graphics window.

Once a mouse click is detected, the red square should move from its current location to the location of the
mouse click.

NOTE: To earn full credit, the square should not disappear and reappear to move across the screen – it must
appear to move smoothly across the window to the mouse click location. An example of this animation is
shown with the Lab Prep 6 assignment on Blackboard.

HINT: It could be helpful to write a separate function that animates the square which will be called
within the
main() function after a mouse click.

The user will be able to click in the Window to move the square five (5) times. After the square reaches the fifth
mouse click location, display a Text object in the center of the Window: “Click to Exit”. One additional
click closes the Graphics window and ends the program without error messages.

Save and Submit your Completed labprep6.py File on Blackboard:

1
Save your program with the file name labprep6.py, and submit it by 11:59 pm on the night before lab.

Lab Prep 6 Grading Rubric

1
2
3
4
5
6
7
8
TODO #1: Program has proper filename and header including student name and description 1
TODO #2: Comments added for each section of code 1
TODO #3: main() function creates Graphics window and red square as specified 2
TODO # 4 : Square animates correctly, moving smoothly to locations of 5 mouse clicks 3
TODO # 4 : "Click to Exit" Text object appears after 5 clicks, program waits for mouse click 1
TODO #4: Graphics window closes and program ends without errors 1
Style / Format: Program is formatted properly and easy to understand 1
Total Points 10
1
Your completed Python file should be named labprep6.py and submitted on BlackBoard.