- Beautiful is better than ugly.
- Explicit is better than implicit.
- Simple is better than complex.
- Complex is better than complicated.
- Flat is better than nested.
- Sparse is better than dense.
- Readability counts.
- Special cases aren't special enough to break the rules.
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
-- Preview the currently active BBEdit document using Marked. For easy access, add as a service. | |
tell application "BBEdit" | |
activate | |
-- Ask BBEdit for it's active document. | |
set the_document to active document of text window 1 | |
-- If the file doesn't alreay exist, ask the user to save it. | |
if not the_document's on disk then |
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
<!-- | |
Sample CSS file that creates multiple 50px by 50px squares of varying color. The yellow square is a link. | |
A Codecademy HTML5 assignment | |
Dr. Steven B. Combs, HTML5 novice | |
--> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Result</title> |
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
# Sample function that utilizes the splat (*) argument to accept multiple input strings | |
# A Codecademy Python assignment | |
# Dr. Steven B. Combs, coding novice | |
def favorite_actors(*actors): | |
"""Prints out your favorite actorS (plural!)""" | |
print "Your favorite actors are:" , actors | |
favorite_actors("Michael Palin", "John Cleese", "Graham Chapman") |
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
# Sample function code to square a number | |
# Identical to the sqrt function in the math module | |
# Dr. Steven B. Combs, coding novice | |
def square(n): | |
"""Returns the square of a number.""" | |
squared = n**2 | |
print "%d squared is %d." % (n, squared) | |
return squared | |
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
# Collection of notes that describe module and function useage | |
# Dr. Steven B. Combs, coding novice | |
# Import basics | |
import module # Imports a module | |
from module import function # Imports a single function from a module | |
from module import * # Imports all functions from a module | |
# Import samples | |
import math # Imports the math module |
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
# Function to determine if number is odd or even | |
# A Codecademy Python (Function and Control) assignment | |
# Dr. Steven B. Combs, coding novice | |
def is_even(x): | |
if x % 2 == 0: # If varialble is divisible by 2 without remainder | |
return "yep" # The variable is even | |
else: | |
return "nope" |
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
# Shutdown Function | |
# A Codecademy Python (Review: Functions) assignment | |
# Dr. Steven B. Combs, coding novice | |
def shut_down(s): | |
if s.lower() == "yes": | |
return "Shutting down..." | |
elif s.lower() == "no": | |
return "Shutdown aborted!" | |
else: |
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
# Number is Integer or Float - return Absolute Function | |
# A Codecademy Python (Review: Built-In Functions) assignment | |
# Dr. Steven B. Combs, coding novice | |
def distance_from_zero(a): | |
"""Integer or Float to Absolute""" | |
if type(a) == int or type(a) == float: | |
return abs(a) | |
else: | |
return "Not an integer or float!" |
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
# Function to determine the minimum payment | |
# A Codecademy Python (Something of Interest) assignment | |
# Dr. Steven B. Combs, coding novice | |
def hotel_cost(nights): | |
return nights * 140 | |
bill = hotel_cost(5) | |
def get_min(balance,rate): |
OlderNewer