cs65 Lab3
cs65 Lab3
You will be creating a python file for each task separately (with a *.py extension), where you will save
your python instructions. By default, Thonny opens an unnamed file in the a text editor (top text pane).
It is an excellent practice to write a formal header and suppress it as comments. A line of code with a
preceding # is considered as a comment in Python. You should type in the necessary parts as shown
below, e.g., your name, your contact email, description, etc.. Save the file using the format as follows first-
name lastname lab3 task*.py (all in lowercase letters). For example, I saved my file as md reza lab3 task3.py.
Driver and navigator: Now, you will be doing collaborative work for this lab. These exercises should
be completed with your assigned partner. Both of you will take turns playing the role of i) the driver and
ii) the navigator. The driver’s responsibility is to type into Thonny when completing each exercise. The
navigator’s responsibility is to support the driver by reading the exercises, looking up relevant readings, and
identifying errors.
Tasks and file submission: This lab consists of several small tasks. We expect that you submit separate
file for each task (a python file with a .py extension). In your python file, add comments to briefly explain
what you are doing. You should submit your individual copy by acknowledging your partner’s name at the
beginning of your python file (inside a comment).
Page 1 of 6
CS65 Lab 3: Graphics library exploration Due: Saturday, Feb 19, 2022
For example, the function above can be called with the following python line:
win default = create circle default coord()
Notice the function returns a variable window, which is defined inside it. When you call the function, you
need to save it in a separate variable. In the example above, it is saved in the variable win default. Can you
tell the difference between the two variables? More precisely – Is window a local-variable or global variable?
How about win default? Write the difference inside your python file as a comment (with a preceding #).
Define the function and call them as instructed. When you run your program, it should prompt you to do
the following:
You should try run your program with different user inputs and see the differences.
Page 2 of 6
CS65 Lab 3: Graphics library exploration Due: Saturday, Feb 19, 2022
You can define a corner (2D point) the same you have defined it for the center of the circle. Here is a sample
function that draws a rectangle.
Instead of hard-coding the values inside the function body, you should ask the user to provide the values
for you. When you define your new function, it should have a different number of parameters. Determine
how many parameters do you need for your new function and finish making the necessary changes inside the
function. Once you define a function, you need to call it in order to see its execution. Define the function
and call them as instructed. When you run your program, it should prompt you to do the following:
You should try run your program with different user inputs and see the differences.
Page 3 of 6
CS65 Lab 3: Graphics library exploration Due: Saturday, Feb 19, 2022
You should try run your program with different user inputs and see the differences.
Page 4 of 6
CS65 Lab 3: Graphics library exploration Due: Saturday, Feb 19, 2022
You should try run your program with different user inputs and see the differences.
Define the function and call them as instructed. Here is the output you should expect to see:
Page 5 of 6
CS65 Lab 3: Graphics library exploration Due: Saturday, Feb 19, 2022
Page 6 of 6