Computational Modeling
ASSIGNMENT 1
FULL SOLUTIONS
UNISA
2025
Assessment 1 (Due date: Friday, 25
April 2025, 11:00 PM)
NAME:___________________
STUDENT NUMBER:_______
Page 1 of 40
,Page 2 of 40
,PHY3709 COMPUTATIONAL MODELING
Assessment 1 (Friday, 25 April 2025, 11:00 PM)
1.1.6 (page 6, optional)
SOLUTION
To determine the center of the circle drawn by the given program, let's analyze the
commands step by step:
1. Initial Position and Orientation:
o The program starts with the turtle at the origin point (0, 0) on the
coordinate plane, facing to the right (east direction).
2. First Command: left(90):
o The left(90) command turns the turtle 90 degrees to the left
(counterclockwise).
o After this command, the turtle will be facing upward (north direction).
3. Second Command: circle(100):
o The circle(100) command draws a circle with a radius of 100 units.
o By default, when the turtle is facing north, the circle is drawn to the left of
the turtle's current direction. This means the center of the circle will be
located 100 units to the left of the turtle's starting position before drawing
the circle.
4. Calculating the Center:
o Before drawing the circle, the turtle is at (0, 0) facing north.
o Since the circle is drawn to the left of the turtle's path, the center will be
at (-100, 0).
Final Answer:
The center of the circle is at the coordinates (-100, 0).
\boxed{(-100,\ 0)}
Page 3 of 40
, 1.1.10 (page 7, optional)
SOLUTIONS
Drawing a Rectangle in Python
Here's a simple Python program using the turtle graphics module to draw a rectangle
that's 100 units wide and 200 units tall:
python
import turtle
# Set up the turtle
screen = turtle.Screen()
pen = turtle.Turtle()
# Draw the rectangle
for _ in range(2):
pen.forward(100) # Width of 100 units
pen.left(90) # Turn 90 degrees
pen.forward(200) # Height of 200 units
pen.left(90) # Turn 90 degrees
# Keep the window open until clicked
screen.exitonclick()
Alternative Version (Using turtle's built-in rectangle function):
Python
import turtle
Page 4 of 40