Skip to content

Instantly share code, notes, and snippets.

@CodeMaster7000
CodeMaster7000 / Typing Test.py
Created December 19, 2021 21:21
A typing test in python to measure your speed and accuracy when typing.
from time import time
def typingErrors(prompt):
global iwords
words = prompt.split()
errors = 0
for i in range(len(iwords)):
if i in (0, len(iwords)-1):
@CodeMaster7000
CodeMaster7000 / Turtle Star.py
Created December 19, 2021 21:32
An impressive turtle star with just a few lines of code.
from turtle import *
speed=0
color('red', 'yellow')
begin_fill()
while True:
forward(200)
left(170)
if abs(pos()) < 1:
break
end_fill()
@CodeMaster7000
CodeMaster7000 / Random Password Generator.py
Last active January 1, 2022 21:53
A Random Password Generator in Python. The output is a string of upper case and lower case letters.
import random
import string
def get_secure_password(length):
result_str = ''.join(random.choice(string.ascii_letters) for i in range(length))
print(result_str)
get_secure_password(8)
@CodeMaster7000
CodeMaster7000 / Hanoi Tower.py
Created December 19, 2021 21:39
A programme for computers to sort different sizes of blocks in order to build the perfect Tower of Hanoi!
from turtle import *
class Disc(Turtle):
def __init__(self, n):
Turtle.__init__(self, shape="square", visible=False)
self.pu()
self.shapesize(1.5, n*1.5, 2)
self.fillcolor(n/6., 0, 1-n/6.)
self.st()
@CodeMaster7000
CodeMaster7000 / Snake.py
Created December 19, 2021 21:44
A snake game coded with Python turtle. Hope you enjoy playing it!
import turtle; import random; import time
delay = 0.08
score = 0
high_score = 0
wn = turtle.Screen()
wn.title("Snake Game")
wn.bgcolor("green")
@CodeMaster7000
CodeMaster7000 / Pygame-Snake.py
Last active January 1, 2022 21:52
A snake game coded in Python (with Pygame). I hope you enjoy playing it!
import pygame
import time
import random
snake_speed = 15
window_x = 720
window_y = 480
black = pygame.Color(0, 0, 0)
@CodeMaster7000
CodeMaster7000 / Alarm Clock.py
Created December 19, 2021 21:51
An Alarm Clock coded in Python 3. Run 'Alarm Clock.py' in a terminal if you have Python 3.
from tkinter import *
import datetime
import time
import winsound
def alarm(set_alarm_timer):
while True:
time.sleep(1)
current_time = datetime.datetime.now()
now = current_time.strftime("%H:%M:%S")
@CodeMaster7000
CodeMaster7000 / Space Invaders.py
Last active December 19, 2021 21:57
Space Invaders coded in Python 3 (with Pygame). I hope you enjoy playing it!
import pygame
class Game:
screen = None
aliens = []
rockets = []
lost = False
def __init__(self, width, height):
@CodeMaster7000
CodeMaster7000 / Christmas Tree of Stars.py
Created December 24, 2021 12:31
A Christmas Tree made out of stars. Merry Christmas everyone!
def triangleShape(n):
for i in range(n):
for j in range(n-i):
print(' ', end=' ')
for k in range(2*i+1):
print('*',end=' ')
print()
def poleShape(n):
for i in range(n):
@CodeMaster7000
CodeMaster7000 / Floyd's Triangle.py
Created December 24, 2021 12:33
Floyd's Triangle in Python 3.
row = int(input('Enter number of rows: '))
number = 1
print('\n')
for i in range(1,row+1):
for j in range(1, i+1):
print(number, end='\t')
number += 1
print()