This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
os.system("cls") #use this for windows. change to os.system("clear") for linux | |
COLORS = {\ | |
"black":"\u001b[30;1m", | |
"red": "\u001b[31;1m", | |
"green":"\u001b[32m", | |
"yellow":"\u001b[33;1m", | |
"blue":"\u001b[34;1m", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<iframe src="https://scratch.mit.edu/projects/PROJECTID/embed" width="800" height="600"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Full tutorial video available at - http://learnlearn.uk/raspberrypi/2018/08/29/make-teleporter-minecraft-using-python/ | |
import mcpi.minecraft as minecraft | |
import mcpi.block as block | |
import time | |
mc = minecraft.Minecraft.create() | |
mc.postToChat("Welcome to my teleporter") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os,sys,time | |
sl = [] | |
try: | |
f = open("shopping2.txt","r") | |
for line in f: | |
sl.append(line.strip()) | |
f.close() | |
except: | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys,time | |
message = "please enter your name: " | |
def typewriter(message): | |
for char in message: | |
sys.stdout.write(char) | |
sys.stdout.flush() | |
if char != "\n": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random,time,os | |
l = [i for i in range(10)] | |
random.shuffle(l) | |
def redraw(arrow = "↑",shift=0,moved_right=False): | |
os.system('cls') | |
print() | |
print("Outer Index:",index, "\tCurrentValue: ",currentValue, "\tInner Index:",currentPosition) | |
print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time,random | |
l = [] | |
for i in range(20): | |
l.append(random.randint(1,1000)) | |
def bubble_sort(l): | |
l = l[:] | |
while True: | |
swapped = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mcpi.minecraft as minecraft | |
import mcpi.block as block | |
import time,math | |
mc = minecraft.Minecraft.create() | |
mc.postToChat("Rainbow World") | |
pos = mc.player.getTilePos() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv,os,time,sys,random | |
def get_maze(file): | |
f = open(file,'r') | |
reader = csv.reader(f) | |
maze = [] | |
for line in reader: | |
maze.append(line) | |
return maze |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from - http://openbookproject.net/thinkcs/python/english3e/recursion.html | |
def get_dirlist(path): | |
""" | |
Return a sorted list of all entries in path. | |
This returns just the names, not the full path to the names. | |
""" | |
try: | |
dirlist = os.listdir(path) | |
dirlist.sort() |
NewerOlder