Side look emoji using turtle

import turtle

my_pen = turtle.Turtle()


my_pen.color("#ffdd00")

my_pen.begin_fill()

my_pen.circle(100)

my_pen.fillcolor("#ffdd00")

my_pen.end_fill()

my_pen.home()


my_pen.goto(-40, 100)

my_pen.color("#555555")

my_pen.begin_fill()

my_pen.circle(15)

my_pen.color("#ffffff")

my_pen.end_fill()

my_pen.penup()

my_pen.goto(-48, 110)

my_pen.pendown()

my_pen.color("Black")

my_pen.begin_fill()

my_pen.circle(5)

my_pen.end_fill()

my_pen.penup()


my_pen.goto(40, 100)

my_pen.pendown()

my_pen.color("#555555")

my_pen.begin_fill()

my_pen.circle(15)

my_pen.color("#ffffff")

my_pen.end_fill()

my_pen.penup()

my_pen.goto(32, 110)

my_pen.pendown()

my_pen.color("Black")

my_pen.begin_fill()

my_pen.circle(5)

my_pen.end_fill()

my_pen.penup()


my_pen.goto(-20, 50)

my_pen.pendown()

my_pen.pensize(10)

my_pen.forward(40)


turtle.done()

Legendre's Conjecture program

import math

def isprime( n ):

i = 2

for i in range (2, int((math.sqrt(n)+1))):

if n%i == 0:

return False

return True

def LegendreConjecture( n ):

print ( "Primes in the range ", n*n

, " and ", (n+1)*(n+1)

, " are:" )

for i in range (n*n, (((n+1)*(n+1))+1)):

if(isprime(i)):

print (i)

n = 50

LegendreConjecture(n)



A clock dial using turtle

import turtle

screen=turtle.Screen()

trtl=turtle.Turtle()

screen.setup(620,620)

screen.bgcolor('black')

clr=['red','green','blue','yellow','purple']

trtl.pensize(4)

trtl.shape('turtle')

trtl.penup()

trtl.pencolor('red')

m=0

for i in range(12):

      m=m+1

      trtl.penup()

      trtl.setheading(-30*i+60)

      trtl.forward(150)

      trtl.pendown()

      trtl.forward(25)

      trtl.penup()

      trtl.forward(20)

      trtl.write(str(m),align="center",font=("Arial", 12, "normal"))

      if m==12:

        m=0

      trtl.home()

trtl.home()

trtl.setpos(0,-250)

trtl.pendown()

trtl.pensize(10)

trtl.pencolor('blue')

trtl.circle(250)

trtl.penup()

trtl.setpos(150,-270)

trtl.pendown()

trtl.ht()

Printing anagrams together using List and Dictionary

def allAnagram(input):

dict = {}

for strVal in input:

key = ''.join(sorted(strVal))

if key in dict.keys():

dict[key].append(strVal)

else:

dict[key] = []

dict[key].append(strVal)

output = ""

for key,value in dict.items():

output = output + ' '.join(value) + ' '

return output

if __name__ == "__main__":

input=['cat', 'dog', 'tac', 'god', 'act']

print (allAnagram(input))


Program for Reversal algorithm for array rotation

def rverseArray(arr, start, end):

while (start < end):

temp = arr[start]

arr[start] = arr[end]

arr[end] = temp

start += 1

end = end-1

def leftRotate(arr, d):

n = len(arr)

rverseArray(arr, 0, d-1)

rverseArray(arr, d, n-1)

rverseArray(arr, 0, n-1)

def printArray(arr):

for i in range(0, len(arr)):

print (arr[i])

arr = [1, 2, 3, 4, 5, 6, 7]

leftRotate(arr, 2)

printArray(arr)