Maths and Computer Science are often taught very separately, and yet they make excellent companions. Writing a program to explore a topic from maths can really help to understand the topic deeply as well as providing a great opportunity to practice your coding skills.
Here’s a challenge: use the Python Turtle Module as described here, to draw a sector of a circle given a radius and an angle. The result should look something like this:
Here’s some skeleton code to get you started:
# Program to draw Sector of a Circle
# Set up Turtle and window
turtle.setup(500,500) # Determine the window size
wn = turtle.Screen() # Get a reference to the window
wn.title("Circle Sectors") # Change the window title
wn.bgcolor("lightgreen") # Set the background color
Crush = turtle.Turtle() # Create our favorite turtle
def draw_sector(angle, radius, t):
# your code here
# Try out the function, giving an angle, a radius and the name of your turtle
draw_sector(40, 100, Crush)
# Allow click to exit
Enjoy, and I’ll post a solution in a few days.