Drawing Emotions with Python Turtle Module (Smiley Face, Frown, Mad, Sick)
HTML-код
- Опубликовано: 3 окт 2024
- Drawing Emotions with Python Turtle Module (Smiley Face, Frown, Mad, Sick). - Use the python turtle module to draw a smiley face, frown face, angry face, or sick face)
Starting code:
import turtle #to include the turtle module in your python program
s=turtle.Screen( ) #create a blank canvas to draw on
t=turtle.Turtle(shape='turtle') # draw with a turtle shape
t.color('pencolor', 'fill color') #specify the line color and fill colors
t.circle(100) #draw a circle with radius 100
thank u
Thank you
Can u paste here the code?
import turtle
emotion = input('How are you? (s=sad, h=happy, m=mad) ')
s = turtle.Screen()
t=turtle.Turtle(shape='turtle')
t.speed(2)
t.color('orange', 'yellow')
if emotion == 'y':
t.color('orange', 'green')
elif emotion == 'm':
t.color('orange', 'red')
t.begin_fill()
t.circle(100)
t.end_fill()
t.penup()
t.color('black', 'red')
#left eye
t.goto(-30, 135)
t.pendown()
t.dot(25)
t.penup()
#right eye
t.goto(30, 135)
t.pendown()
t.dot(25)
t.penup()
#mouth
if emotion == 'h':
t.goto(-60, 60)
t.pendown()
t.setheading(-60)
t.circle(70, 120)
else:
t.goto(60, 60)
t.pendown()
t.setheading(120)
t.circle(70, 120)
Please answer how do you open the app thingy please answer
The IDE (Integrated Development Environment) I am using to create the python program is IDLE. It comes with python when you install.
Can/how does one make specific arcs?
t.circle(70, 120) means go from current position and heading for curve of 120 degrees on circle with radius 70. There is example arc for the smile, starting at 6:00 with detailed information about radius and angle at 7:00.