Colorful Spiral Web Using Turtle Graphics in Python

import turtle

colors = ['red', 'yellow', 'green', 'purple', 'blue', 'orange']

s= turtle.Pen()

s.speed(10)

turtle.bgcolor("black")

for x in range(200):

s.pencolor(colors[x%6]) 

s.width(x/100 + 1) 

s.forward(x) 

s.left(59) 

turtle.done()

s.speed(20)

turtle.bgcolor("black") 

for x in range(200):

s.pencolor(colors[x%6]) 

s.width(x/100 + 1) 

s.forward(x) 

s.left(59) 

turtle.done()


Remove all duplicates words from a given sentence

from collections import Counter

def remov_duplicates(input):

input = input.split(" ")

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

input[i] = "".join(input[i])

Uniq = Counter(input)

s = " ".join(Uniq.keys())

print (s)

if __name__ == "__main__":

input = 'Python is great and Java is also great'

remov_duplicates(input)


Program to Create a Lap Timer

import time

starttime=time.time()

lasttime=starttime

lapnum=1

print("Press ENTER to count laps.\nPress CTRL+C to stop")

try:

while True:

input()

laptime=round((time.time() - lasttime), 2)

totaltime=round((time.time() - starttime), 2)

print("Lap No. "+str(lapnum))

print("Total Time: "+str(totaltime))

print("Lap Time: "+str(laptime))

print("*"*10)

lasttime=time.time()

lapnum+=1

except KeyboardInterrupt:

print("Done")


Program to find yesterday’s, today’s and tomorrow’s date

from datetime import datetime, timedelta

currentday = datetime.now()

yesterday = currentday - timedelta(1)

tomorrow = currentday + timedelta(1)

print("Yesterday = ", yesterday.strftime('%d-%m-%Y'))

print("Today = ", currentday.strftime('%d-%m-%Y'))

print("Tomorrow = ", tomorrow.strftime('%d-%m-%Y'))


Program to Print Matrix in Z form

arr = [[5, 6, 7, 8],

    [1, 2, 3, 4],

    [5, 6, 7, 8],

    [9, 8, 7, 5]]

a = len(arr[0])

i=0

for j in range(0, a-1):

print(arr[i][j], end =" ")

k = 1

for i in range(0, a):

for j in range(a, 0, -1):

if(j==a-k):

print(arr[i][j], end = " ")

break;

k+=1

i=a-1;

for j in range(0, a):

print(arr[i][j], end = " ")