代写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:
- Setup your Python file labprep6.py with an appropriate comments header
- Organize labprep6.py using comments for each block of planned code
- In each block, write the necessary Python code to complete the task
- 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 | execute these commented lines; they are used to make the program easier to understand. In the Python IDLE |
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 |
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 | TODO #1: Program has proper filename and header including student name and description 1 |
1 | Your completed Python file should be named labprep6.py and submitted on BlackBoard. |