Drawing a crescent moon with Python codes


Greetings guys,

i hope everyone is doing great. about last week, i saw contest that really caught my attention and
im here to particpate in this contest. But before i continue, i want to thank @threespeak for partnering up with @diyhub in organizing this wonderful contest. as some of you know, i love coding so i decided to do something unique by writing a code in python that will draw a cresent moon on my computer. lets head straight into it.

The first thing you need to do is, call the turtle finction because we will be using it to draw the cresent like shape. we call the turtle function as t by typing "import turtle as t".


Now after defining the function, its now left with defining the turtle, the background color, the positioning and more. for the background color we can define it with t as in turtle .bg('black'). for the postion of the moon we can center it in the middle for which we can use t.goto(0, 200)


we are now almost half way through our code, the next thing we need to do it, now define the colour of the moon, which obviously is white. After which we have to set the circle to the middle again with radius of 200

For thid next part, we are going to repeat or copy the code we already wrote in the begining. copy the code from line 2 to line 8 and paste them in the next line. the are some changes we will make in this codes t.goto(50, -200) becomes the new line 11 and t.color('black') becomes the new line 13
we end the code with a t.hideturtle(). you can choose to stop here if you want to. but i would advise you import this funtion at the end import turtle;turtle.exitinclick(). this code still keeps the turtle pop up still active unless you click anywhere on the screen to exit it.

Now run the code. and you should see a full moon which is then later changed to a cresent moon

i urge each and everyone to try their best to participate in this amazing contest. i would love to read about your thoughts on the code, wethere you would try it out and the results you get. im also open to any question you might have thank you.


▶️ 3Speak

H2
H3
H4
3 columns
2 columns
1 column
3 Comments
Ecency