This is the first homework assignment. Our goal in this homework is to consolidate your understanding of the concept of a computer program, its execution, and effects this execution entails. Along the way, it is also important that you get familiar with the Python programming environment, and take your first step towards learning how to use it effectively.

Practical information#

The assignment is due on Sunday the 5th of March, at 11.55am (five minutes before noon). To submit your solution, you will upload a single Python file circles.py via Wattle. Here is the assignment submission link.

In addition to submitting your solution, you must attend the lab in week 3. In the lab, you will have a chance to discuss some questions about the assignment. Your tutor may also ask you some questions about your solution, and give you feedback if there is anything you need to improve. This discussion is NOT part of the assessment.

The homework is individual. You must write your own solution, and you are expected to be able to explain every aspect of it. Also remember that you are not allowed to share your solution (code) with other students; this includes posting it (or parts of it) to the discussion forum, or to any other on-line forum.

If you have followed the lectures and worked through the exercises in lab 1, the assignment should not take more than one to two hours to complete.

The problem#

Your task in this homework is to write several (nine, to be precise) print function calls to make your program output a circle made of simple characters like * and - (and a few others), so called “ascii art”. What your program prints out should look like this


                              -
                          *      *
                        *           *
                      /               \
                     (        x        )
                      \               /
                        *           *
                          *      *
                              -

The circle centre should also be marked, and its horizontal coordinate must be defined as a variable before print calls (for example, x=30), such that by changing its value the circle will shift left or right. Make your program to print three such circles at different horizontal positions, one under another. The centre horizontal coordinate can be always greater than the circle radius to avoid clipping. Think how repetition in calling print functions can be avoided (Hint: by defining your own function).

The file circles.py where you shall write you code should be downloaded using the link below:

Remember to write your university ID and name in the beginning of the file which you will submit. Do not change the file name (leave it circles.py as it was originally).

Marking#

What to submit

You should edit the file circles.py that you downloaded, then upload only this file with your solution using the assignment submission link on Wattle.

The file that you submit must meet the following requirements:

  • It must be syntactically correct Python code.
  • The file can include the import statements, and you can (and should!) use comments.

As mentioned above, you should also attend the lab (in week 3) where you will have a chance to discuss your solution. This discussion is NOT part of the assessment. These are some of the questions which you can discuss:

  • How to download the file that you submitted from Wattle?
  • How to run that file in the Python interpreter using an IDE of your choice?
  • Can you explain the algorithm of your solution in simple terms? Can you think of a different approach to the problem? Can you decide which of the approaches are better?
  • If the file has syntax errors, can you use the error messages from the interpreter or IDE to identify where the syntax errors are?
  • Does your submitted file meet the requirements stated above? Can you identify what kind of statements your program is made of (function calls, assignments, function definitions, import statements)?

In marking this assignment we will consider the following:

  • Does your submitted file satisfy the requirements specified above?
  • Do you define a function to print a circle at a prescribed horizontal location? Do you avoid repetitions when printing circles at different horizontal position?
  • Your ability to use the tools (e.g., the IDE or Python interpreter), your understanding of Python’s error messages, and your understanding of the solution, as demonstrated in your discussion.

The assignment is worth 2% of your final mark.

bars search times arrow-up