Draw a Superman logo using Python programming | Python Turtle Graphics | Code Hub

MNC Answers
0

 What is Turtle in Python

Turtle is like a drawing board in Python, which lets us command a turtle to draw over where we have insisted the direction like forward(), backward(), etc.


How to use Turtle

1. We need to import the "Turtle" package

2. We have to create a turtle where we need to control 

3. Give direction to draw around using the turtle methods

4. Finally, run turtle.done()

Note:

You can install these libraries using pip command.

import the required package to draw the logo.

Turtle is pre-installed in mostly all programming software if Turtle is not  installed please use this pip command  pip install PythonTurtle


Video Output:

Source Code:

import turtle 


t=turtle.Turtle() 

turtle.Screen().bgcolor('#5767B9') 


def curve(value): 

    for i in range(value): 

        t.right(1) 

        t.forward(1)


t.penup() 

t.setposition(0,43) 

t.pendown() 

t.begin_fill() 

t.pencolor('black') 

t.fillcolor('maroon') 

t.pensize(3) 

t.forward(81.5) 

t.right(49.4) 

t.forward(58) 

t.right(81.42) 

t.forward(182) 

t.right(98.36) 

t.forward(182) 

t.right(81.42) 

t.forward(58) 

t.right(49.4) 

t.forward(81.5) 

t.end_fill() 

t.penup() 


t.setposition(38,32) 

t.pendown() 

t.begin_fill() 

t.fillcolor('gold') 

t.forward(13) 

t.right(120)

t.forward(13) 

t.right(120) 

t.forward(13) 

t.end_fill() 

t.penup() 


t.setposition(81.5,25) 

t.pendown() 

t.begin_fill() 

t.right(210) 

t.forward(25) 

t.right(90) 

t.forward(38) 

t.right(45) 

t.circle(82,90) 

t.left(90) 

t.circle(82,60) 

curve(61) 

t.left(90) 

t.forward(57)

t.left(90) 

t.forward(32) 

t.end_fill() 

t.penup() 

t.home() 


t.setposition(-69,-38) 

t.pendown()

t.begin_fill()

curve(20)

t.forward(33)

t.left(10)

t.circle(82,20)

curve(30)

t.forward(10)

t.right(110)

curve(40)

t.right(10)

t.circle(50,10)

curve(45)

t.right(5)

t.forward(45)

t.end_fill()

t.penup()

t.home()


t.setposition(20,-100)

t.pendown()

t.begin_fill()

t.right(135)

t.forward(27)

t.right(90)

t.forward(27)

t.right(135)

t.forward(38.18)

t.end_fill()

t.penup()

t.home()


t.setposition(-57,32)

t.pendown()

t.begin_fill()

t.right(180)

t.forward(18)

t.left(45)

t.forward(44)

t.left(80)

t.forward(15)

t.left(130)

curve(40)

t.forward(20)

t.end_fill()


t.hideturtle() 

turtle.exitonclick()(code-box)


Output :  

Draw a Superman logo using Python programming | Python Turtle Graphics | Code Hub



Tags

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
Youtube Channel Image
MM4Tech Subscribe To watch more Tutorials
Subscribe