def printCalendar(): now = datetime.now() print(colors.CLEAR, colors.at(4, 1)) print(" M Tu W Th F Sa Su") printMonth(now.year, now.month, row=6) (days, workdays) = countWorkDays(datetime(2020, 6, 20)) print() print(f" {colors.RED}{days} {colors.GREEN}days to summer!") print(f" {colors.RED}{workdays} {colors.GREEN}workdays to summer!") print(colors.NORMAL, end="")
def printDay(date, row): print(colors.at(row, 2 + (4 * date.weekday())), end="") if date.day == now.day: print(colors.YELLOW, end="") elif isHoliday(date): print(colors.PURPLE, end="") elif isWeekend(date): print(colors.RED, end="") else: print(colors.WHITE, end="") print(date.day)
def box(row, col, width, height): width = width - 2 # Subtract 2 for the left and right sides end = row + height-1 print colors.at(row, col) + u'\u2554' + u'\u2550'*width + u'\u2557' for i in range(row+1, end): print colors.at(i, col) + u'\u2551' + " "*width + u'\u2551' print colors.at(end, col) + u'\u255A' + u'\u2550'*width + u'\u255D'
def box(row, col, width, height): width = width - 2 # Subtract 2 for the left and right sides end = row + height - 1 print colors.at(row, col) + u'\u2554' + u'\u2550' * width + u'\u2557' for i in range(row + 1, end): print colors.at(i, col) + u'\u2551' + " " * width + u'\u2551' print colors.at(end, col) + u'\u255A' + u'\u2550' * width + u'\u255D'
def printClock(): now = datetime.now() print(colors.at(1, 1)) hour = now.hour % 12 minute = now.minute ampm = "am" if now.hour < 12 else "pm" clock_face = now.strftime(f" It is {hour}:{minute} o'clock in the {ampm} ") print(f"{clock_face:^27}") month_face = f"{now.day} {month(now)} {now.year}" print(f"{month_face:^27}") print()
def showTime(now): print colors.GREEN box(9, 10, 4, 3) print colors.RED print(colors.at(10, 11) + str(now.hour % 12)) print colors.GREEN box(9, 13, 4, 3) print colors.RED print(colors.at(10, 14) + str(now.minute)) print colors.GREEN box(9, 16, 4, 3) print colors.RED print(colors.at(10, 17) + str(now.second)) print colors.GREEN box(9, 19, 4, 3) print colors.RED meridian = "AM" if now.hour > 12: meridian = "PM" print(colors.at(10, 20) + meridian)
def showDay(now): print colors.GREEN box(6, 10, 21, 3) print colors.BLUE print(colors.at(7, 11) + formatDate(now))
# A few imports. Math for pow, random for randint, # colors for ANSII Terminal things, time to sleep. import math import random import colors import time # An 8 frame animation for i in range(1, 9): # Clear the screen print colors.CLS # Hi # Lo # scrolls down the marquee print colors.at(i, 38), colors.GREEN, "Hi" print colors.at(i+1, 40), colors.RED, "Lo" # Half-second delay in each frame time.sleep(0.5) # Reset the colors print colors.NORMAL # Print the instructions, one line at a time, after the last line of # the intro scroll, aligned right. print colors.BOLD print "This is the game of HiLo" print colors.NORMAL print "You will have 6 tries to guess the amount of money in the" print "HiLo jackpot. If you guess the right amount, you win all" print "the money in jackpot. However, if you lose, you lose all"
import colors print colors.at(8, 10) print "Foo"
def print_clock(when): clock_face = when.strftime("%a, %B %d of the year %Y at %I:%M:%S%p") print(colors.at(5, 5) + clock_face)
def title(): print colors.CLS print colors.at(8, 20) + "Lander!"
def title(): print colors.CLS print colors.at(8, 20) + "Lander!" def instructions(): print "This is a simulation of an Apollo Lunar" print "landing capsule.\n\n" print "The on-board computer has failed, so you" print "have to land the capsule manually.\n" print "Set the burn rate of the retro rockets" print "to any value between 0 (free fall) and 200" print "(maximum thrust) pounds per second. Set a new" print "burn rate every 10 seconds.\n" print "Capsule weight is 32,500 lbs; fuel weight 16,500 lbs" print "\n\n\nGood luck!\n\n\n" fuel = 0 def play(): print fuel title() pressEnter() print colors.CLS print colors.at(5, 1) instructions() pressEnter() play()
# A few imports. Math for pow, random for randint, # colors for ANSII Terminal things, time to sleep. import math import random import colors import time # An 8 frame animation for i in range(1, 9): # Clear the screen print(colors.CLEAR) # Hi # Lo # scrolls down the marquee print(colors.at(i, 28), colors.GREEN, "Hi") print(colors.at(i + 1, 30), colors.RED, "Lo") # Half-second delay in each frame time.sleep(0.5) # Reset the colors print(colors.NORMAL) # Print the instructions, one line at a time, after the last line of # the intro scroll, aligned right. print(colors.BOLD) print("This is the game of HiLo") print(colors.NORMAL) print("You will have 6 tries to guess the amount of money in the") print("HiLo jackpot. If you guess the right amount, you win all") print("the money in jackpot. However, if you lose, you lose all")