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
BLOCK_COLOURS = "purple", "lightgreen", "lightblue", "orange" | |
for n_block in range(8): | |
# stuff | |
colour = BLOCK_COLOURS[n_block % len(BLOCK_COLOURS)] | |
print(colour) |
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 itertools | |
BLOCK_COLOURS = "purple", "lightgreen", "lightblue", "orange" | |
colours = itertools.cycle(BLOCK_COLOURS) | |
for n_block in range(8): | |
colour = next(colours) | |
print(colour) |
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
from __future__ import with_statement | |
import os, sys | |
import htmlentitydefs | |
import itertools | |
import operator | |
import posixpath | |
import re | |
import sgmllib | |
import tempfile |
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
fizz = 5 | |
buzz = 7 | |
counter = 1 | |
while counter <= 60: | |
fizz_num = counter % fizz | |
buzz_num = counter % buzz | |
if fizz_num == 0: | |
print("Fizz") | |
elif buzz_num == 0: |
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
name = input("Hi, what's your name?") | |
year = input("Hi " + name + " what year were you born in?") | |
month = input("What month were you born in?") | |
day = input("What day were you born in?") | |
age = 0 | |
counter = 1 | |
check = input("just making sure, you were born on " + day +"/"+ month +"/"+ year + " ,correct?") | |
if check == "yes": | |
print("Great!!") |
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 | |
import site | |
def munged(text): | |
user_profile = os.environ['USERPROFILE'].lower() | |
return text.lower().replace(user_profile, "[user]") | |
with open("pr726.log", "w") as f: | |
f.write("CWD: %s\n" % munged(os.getcwd())) | |
f.write("File location: %s\n" % munged(__file__)) |
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 | |
print(sys.executable) |
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
# | |
# You nearly always just need to import Image | |
# from PIL(low) to do what you need | |
# | |
from PIL import Image | |
# | |
# It's convenient to import everything from colorzero | |
# so you don't have to put "colorzero." before everything | |
# | |
from colorzero import * |
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
book_file = open("""bleak-house.txt""") | |
book_text = book_file.read() | |
print(book_text[:200]) | |
words = book_text.lower().split() | |
print(words[:200]) | |
input_word=input("Please enter a word: ").lower() | |
print(input_word) | |
print(len(words), "words") | |
if input_word in words: | |
print("Found it") |
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 | |
import subprocess | |
## env = {} | |
## env['SystemRoot'] = os.environ['SystemRoot'] | |
env = dict(os.environ) | |
del env['PYTHONPATH'] | |
print(subprocess.run(["c:/temp/mu/yyy/scripts/python.exe", "-c", 'import sys; print(sys.path)'], stdout=subprocess.PIPE, env=env).stdout) | |
print(subprocess.run(["c:/temp/mu/yyy/scripts/python.exe", "-m", "pip", "freeze"], stdout=subprocess.PIPE, env=env).stdout) |
OlderNewer