How to propose your crush using python programming language || 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 propose your crush using python programming language || Code Hub


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

import random

wn = turtle.Screen()

wn.setup(width=800, height=800)

t = turtle.Turtle()

turtle.bgcolor("black")

t.pensize(3)

t.pencolor("white")

 

 

def myPosition(x,y):

    t.penup()

    t.goto(x,y)

    t.pendown()

 

myPosition(-200,0)

t.forward(60)

t.left(90)

t.forward(20)

t.left(90)

t.forward(20)

t.right(90)

t.forward(60)

t.right(90)

t.forward(20)

t.left(90)

t.forward(20)

t.left(90)

t.forward(60)

t.left(90)

t.forward(20)

t.left(90)

t.forward(20)

t.right(90)

t.forward(60)

t.right(90)

t.forward(20)

t.left(90)

t.forward(20)

t.right(270)

myPosition(0,0)

 

 

 

def curve():

    for i in range(200):

        t.right(1)

        t.forward(1)

 

def hi():  

    t.fillcolor('red')

    t.begin_fill()

    t.left(140)

    t.forward(113)

    curve()

    t.left(120)

    curve()

    t.forward(112)

    t.end_fill()

 

hi()

t.ht()

myPosition(140,0)

t.left(140)

t.forward(90)

t.left(90)

t.forward(100)

t.left(90)

t.forward(20)

t.left(90)

t.forward(80)

t.right(90)

t.forward(50)

t.right(90)

t.forward(80)

t.left(90)

t.forward(20)

t.left(90)

t.forward(100)

turtle.done() (code-box)


output:

How to propose your crush using python programming language || Code Hub


F.A.Qs - 

1) What is Python ?

Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically-typed and garbage-collected. Read more https://en.wikipedia.org/wiki/Python_...)


2) What is turtle / turtle graphics ?

Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon in 1967. Read more https://docs.python.org/3/library/tur...

3) Which software is used to execute code ?

Visual studio code    

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