In [1]:
%%html
<style>
.example1 {
 height: 50px;	
 overflow: hidden;
 position: relative;
}
.example1 h3 {
 font-size: 3em;
 color: red;
 position: absolute;
 width: 100%;
 height: 100%;
 margin: 0;
 line-height: 50px;
 text-align: center;
 /* Starting position */
 -moz-transform:translateX(100%);
 -webkit-transform:translateX(100%);	
 transform:translateX(100%);
 /* Apply animation to this element */	
 -moz-animation: example1 15s linear infinite;
 -webkit-animation: example1 15s linear infinite;
 animation: example1 15s linear infinite;
}
/* Move it (define the animation) */
@-moz-keyframes example1 {
 0%   { -moz-transform: translateX(100%); }
 100% { -moz-transform: translateX(-100%); }
}
@-webkit-keyframes example1 {
 0%   { -webkit-transform: translateX(100%); }
 100% { -webkit-transform: translateX(-100%); }
}
@keyframes example1 {
 0%   { 
 -moz-transform: translateX(100%); /* Firefox bug fix */
 -webkit-transform: translateX(100%); /* Firefox bug fix */
 transform: translateX(100%); 		
 }
 100% { 
 -moz-transform: translateX(-100%); /* Firefox bug fix */
 -webkit-transform: translateX(-100%); /* Firefox bug fix */
 transform: translateX(-100%); 
 }
}
</style>

Introduction to Computing for Engineers and Computer Scientists

Chapters 5, 6: Functions, Files, HW3

Questions, Discussion

From Class

Piazza

Observation on HW2

Parameters versus Global Values

Functions

The Practice of Computing Using Python (3rd Edition) 3rd Edition by William F. Punch (Author), Richard Enbody (Author), ISBN-13: 978-0134379760, © 2017. Chapter 5.

Overview

  • From Mathematics we know that functions perform some operation and return one value.
    • This value may consist of sub-values, dimensions, etc. For example there may many functions of the form,

      \begin{equation} F:\mathbb{R^n}\rightarrow \mathbb{R^m} \end{equation}
    • The range of the function may be multi-dimensional/composite, but a function maps to exactly one element for any given input.
  • Python functions "encapsulate" the performance of some particular operation, so it can be used by others (for example, the sqrt() function).
  • Why use functions?
    • Support divide-and-conquer strategy for complex functions.
    • Decomposition strategy for solving complex problems with many simpler, reusable functions and algorithms.
    • Abstraction of an operation. Hides complexity from caller.
    • Reuse. Once written, use again.
    • Sharing. If tested, others can use.
    • Security. Well tested, then secure for reuse.
    • Simplify code. More readable.
  • Comments on initial reviews of HW2
    • I defined HW2 as a set of tasks. Many of the tasks map to one or more general purpose, reusable functions.
    • Some/many of you implemented your solution as one relatively large, monolithic sequence of statements. Others implemented functions that perform multiple, independent tasks.
    • We will not take off points in HW2. The solution we publish will demonstrate use of functions and decomposition. I have gone over the concept in class.
    • HW3 will require better design with reusable functions and decomposition.
    • Some terms:
      • A divide and conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same or related type, until these become simple enough to be solved directly. The solutions to the sub-problems are then combined to give a solution to the original problem.
      • Decomposition) in computer science, also known as factoring, is breaking a complex problem or system into parts that are easier to conceive, understand, program, and maintain.
      • In software engineering, a monolithic application describes a software application which is designed without modularity. Modularity is desirable, in general, as it supports reuse of parts of the application logic and also facilitates maintenance by allowing repair or replacement of parts of the application without requiring wholesale replacement.
    • E1006 is about computing, not just Python programming.
      • The course is a requirement $\Rightarrow$ some students know Python and programming and are "phoning it in."
      • Many students in my advanced classes write some of the crappiest code I have ever seen.
      • Some students that can program python skip lectures because they have programmed in Python. This course is about computing and introduction of software engineering.
      • This is important. Interviewers and internships take software engineering seriously.
      • Poor software engineering and design may negatively affect exam scores.
Karma Bus

Example

  • Converting from Celsius to Fahrenheit, metric to US customary units, etc. is a common, recurring program requirement.
  • Consider a function which converts temperatures in Celsius to temperatures in Fahrenheit.

\begin{equation} f(c) = c * 1.8 + 32.0 \end{equation}

  • You could repeatedly embed the snippet of code in many programs in many places.
In [ ]:
#
#
# Imagine a lot of statements
f = c * 1.8 + 32.0
#
# in a ln a lot of programs
#
  • Embedding the formula creates problems
    • Some programmer, sometime, somewhere will make a careless mistake, e.g. type 1.6 or replace $*$ with $+.$ It's just a matter of time.
    • We decide to evolve the large bode of code to use Celsius instead of Fahrenheit and need to find all the places we embedded code snippets like the one above.
    • Finding and changing is tedious and error prone. The snippets may look vastly different.
In [ ]:
#
f = c * 1.8 + 32.0
#
#
temp_f = temp_c * (212-32)/100 + 32
#
#
  • A much better approach is a reusable function.
In [107]:
# Copyright 2017, 2013, 2011 Pearson Education, Inc., W.F. Punch & R.J.Enbody
# Temperature conversion

def celsius_to_fahrenheit(celsius_float):
    """ Convert Celsius to Fahrenheit."""
    return celsius_float * 1.8 + 32
In [109]:
freezing_c = 0
freezing_f = celsius_to_fahrenheit(freezing_c)
print("The Fahrenheit water freezing temperature is ", freezing_f)
The Fahrenheit water freezing temperatur is  32.0
  • Some comments in the example
    • The calling code and the function are often (usually) in different Python programs/files.
    • Naming
      • You know my opinion of names like "celsius_float."
      • "celsius_to_fahrenheit," and "freezing_f" are good names.
  • Terminology: In the example
    • "freezing_c" is an argument.
    • "celsius_float" is a parameter.
  • A parameter is a variable
    • Visible only within the function. No other code can access the parameter.
    • Set to the value of the argument for the specific, individual function call.
  • This is a simple example. Understanding the importance of the modular programming and decomposition approach is difficult to understand from small examples, but ...
    • Becomes more obvious in larger programs that multiple teams develop.
    • Easier to value when you have learned from experience.

I may not be able to tell you the correct way to do things. But, I know a lot of mistakes to avoid.

Mistakes

Python Function Definition

  • Is a compound statement. "Compound statements contain (groups of) other statements; they affect or control the execution of those other statements in some way."
  • We have seen other compound statements:
    • for ...
    • while ...
    • if ...
Function Definition
  • Comments
    • The return statement indicates the value that is returned by the function. The statement is optional (the function can return nothing). If no return, function is often called a procedure.
    • The code in the function suite usually calls other functions.
  • The function again
In [ ]:
# Copyright 2017, 2013, 2011 Pearson Education, Inc., W.F. Punch & R.J.Enbody
# Conversion program

def celsius_to_fahrenheit(celsius_float):
    """ Convert Celsius to Fahrenheit."""
    return celsius_float * 1.8 + 32
  • A triple quoted string just after the def is called a docstring.
    • docstring is documentation of the function's purpose, to be used by other tools to tell the user what the function's purposes and uses.
    • Will cover later.

Python Function Execution

Function Call
Function Return
Function Statement Execution

Software Design Principle

  • A function's operation should be completely defined by
    • The parameters.
    • Statements it executes, including calls to other functions.
    • Well-defined constants, e.g. 1.8.
  • A function should not access external, variable data.
  • The follow code, which some of you wrote is a software anti-pattern.
In [117]:
import math

test = [727.7, 1086.5, 1091.0, 1361.3, 1490.5, 1956.1]

def compute_mu(data):
    total = 0
    count = len(data)
    for i in range(0,count):
        total += data[i]
        
    result = total/count
    
    return result

mu = compute_mu(test)
print("Mu = ", mu)

# The function needs/uses mu, but mu is not a parameter.
# Big mistake.
def compute_sigma(data):
    total = 0
    for n in data:
        total += (mu - n)**2
        
    result = math.sqrt(total/(len(data)-1))
    return result


sigma = compute_sigma(test)
print("Sigma = ", sigma)
Mu =  1285.5166666666667
Sigma =  420.96248961952256
  • compute_sigma relies on an external variable. This is an anti-pattern.
    • Mu could get changed between call to average and standard deviation.
    • Programmer could forget to change mu.
    • Programmer may call compute_sigma from another Python program and not know how to set mu.
    • etc.

Anti-patterns: Don't be "that guy."

"An anti-pattern is a common response (solution) to a recurring problem that is usually ineffective and risks being highly counterproductive"

Don't be "that guy."

Some Function Design Principles

  • A well-design function:
    • Does one thing. If it does too many things, it should be broken down into multiple functions refactored/decomposed.
    • Is readable. How often should we say this? If you write it, it should be readable. (You know. Like an essay. Or lyric poem)
    • Is reusable. If it does one thing well, then when a similar situation (in another program) occurs, use it there as well.
    • Is complete. A function should check for all the cases where it might be invoked. Check for potential errors.
    • Is not too long. Kind of synonymous with do one thing. Use it as a measure of doing too much.
  • In the above example,
    • compute_mu and compute_sigma are independent of the application.
    • And would be compute_mean and compute_standard_deviation in a library.
    • And in fact are. I had you write these functions to understand Python functions, loops, math, etc.

Function and Returns

  • Procedures
    • Functions that have no return statements are often called procedures.
    • Procedures are used to perform some duty (print output, store a file, etc.)
    • Remember, return is not required.
  • A function can have multiple return statements.
    • Remember, the first return statement executed ends the function.
    • Multiple returns can be confusing to the reader and should be used judiciously.

Rules So Far ...

  1. Think before you program!

  2. A program is a human-readable essay (or lyric poem for those so inclinded) on problem solving that also happens to execute on a computer.

  3. The best way to imporve your programming and problem solving skills is to practice!

  4. A foolish consistency is the hobgoblin of little minds

  5. Test your code, often and thoroughly (aka "The Thank You Captain Obvious Rule")

  6. If it was hard to write, it is probably hard to read. Add a comment.

  7. All input is evil, unless proven otherwise. (Will get back to this one)

  8. A function should do one thing.

Functions, HW3 Preview and Future Assignments

  • We are going to implement a very simple spell checker that makes "Did you mean ...?" suggestions.
  • The word is misspelled if it is not in the dictionary. Easy enough to check, and you will.
  • But how do you find suggested changes?
  • One approach is to find correctly spelled words that are "close" to the unrecognized words.
Levenshtein Distance
  • This is a recursively) defined function, which is a type of function we will learn to implement.
  • Computing the LD for all words and finding "the closest" is inefficient. Why compute the distance for completely different words?
  • A better approach to to "guess an error, correct, and see if that word is in the dictionary."
  • A common error is transposing characters: The word is "mouse" but the person typed "muose."
  • Write a generate guess function that produces possible correct spellings.
In [119]:
def generate_transposes(word):
    result = []
    # This was NOT that that hard to write, but ...
    # is not easy to understand and I should have a comment or two,
    for i in range(0,len(word)-1):
        l = word[:i]
        c1 = word[i]
        c2 = word[i+1]
        r = word[i+2:]
        n = l + c2 + c1 + r
        result.append(n)

    return result
In [122]:
bad_word = "muose"
possible_words = generate_transposes(bad_word)
print("Possible words are: ", possible_words)
Possible words are:  ['umose', 'mouse', 'musoe', 'muoes']
  • HW3's core is
    • A function that takes a word input, checks a dictionary and suggests corrections if necessary.
    • Suggesting corrections will be
      • Applying several simple functions that generate possible correct words by
        • Transposing letters.
        • Replacing letters.
        • Inserting letters.
        • Splitting words.
        • etc.
      • Checking if possible corrections are in the dictionary.
      • Recommending corrections based on
        • How close the correction is to the misspelled word.
        • How often is the corrected word actually used? "thg" could be "thy, the, thug, ..." "thy" is unlikely because not commonly used.
  • We will do in the connect of a web application and HTML, but the core is excellent practice with
    • Strings
    • Functions
    • if, for, while, ...
    • Simple algorithm design
    • Decomposition

Files

Overview

  • A file is a collection of data (bytes) that is stored on secondary storage like a disk or a thumb drive.
  • Accessing a file means establishing a connection between the file and the program and moving data between the two.


CPU, RAM, Files
  • Files come in two general types:
    • Text files. Files where control characters such as "/n" are translated and bytes are translated into characters/strings.
      • These files are generally human readable.
      • They may be strings of text, or have a "schema," e.g. CSV.
    • Binary files. All the information is taken directly without translation. Not readable and contains non-readable info. Examples are .jpg, .exe, etc.
  • File object (file stream):
    • When opening a file, you create a file object or file stream that is a connection between the file information on disk and the program.
    • The stream contains a buffer of the information from the file, and provides the information to the program.
  • You can think of the stream being a sequence of characters or bytes. The sequence can be huge, and the input/output system optimizes reading and writing to/from storage.
Input/Output (I/O)
  • Buffers
    • Reading from a disk is very slow.
    • Reading a large number of characters, e.g. 64 KB, takes as long as reading one character.
    • Thus the computer will read a lot of data from a file in the hopes that, if you need the data in the future, it will be buffered in the file object.
    • This means that the file object contains a copy of information from the file called a cache (pronounced "cash")
Memory Access Times

Reading Files

In [127]:
f = open("AAPL.csv","r")
s = f.readline()
print("The first line of text is \n" + s)
print("The first five characters of the next line of text are \n")
s = f.readline(5)
print(s)
print("The 10 characters after that are + \n")
s = f.readline(10)
print(s)
f.close()
The first line of text is 
Date,Open,High,Low,Close,Adj Close,Volume

The first five characters of the next line of text are 

2018-
The 10 characters after that are + 

01-02,170.
In [130]:
print("File 'paths' follow the conventions of the OS directory/folder structure.")
f = open("/Users/donaldferguson/Documents/GitHub/e1006s18/Notebooks/AAPL.csv","r")
print("The first 5 lines are:")

for i in range(0,5):
    print(f.readline())
    
f.close()
File 'paths' follow the conventions of the OS directory/folder structure.
The first 5 lines are:
Date,Open,High,Low,Close,Adj Close,Volume

2018-01-02,170.16000400000001,172.300003,169.259995,172.259995,172.259995,25555900

2018-01-03,172.529999,174.550003,171.96000700000002,172.229996,172.229996,29517900

2018-01-04,172.53999299999998,173.470001,172.080002,173.029999,173.029999,22434600

2018-01-05,173.440002,175.369995,173.050003,175.0,175.0,23660000

In [137]:
print("File 'paths' follow the conventions of the OS directory/folder structure.")
f = open("/Users/donaldferguson/Documents/GitHub/e1006s18/Notebooks/AAPL.csv","r")
print("The first 5 lines are just line any other strings:")

file_lines = []
for i in range(0,5):
    file_lines.append(f.readline())
    
print("file_lines is a 'list' of strings, which are sequences of text. The list =")
print(file_lines)
print("")
print("And let's do some string stuff ...")
s = file_lines[0]
print("The first string backwards is", s[-1::-1])
f.close()
File 'paths' follow the conventions of the OS directory/folder structure.
The first 5 lines are just line any other strings:
file_lines is a 'list' of strings, which are sequences of text. The list =
['Date,Open,High,Low,Close,Adj Close,Volume\n', '2018-01-02,170.16000400000001,172.300003,169.259995,172.259995,172.259995,25555900\n', '2018-01-03,172.529999,174.550003,171.96000700000002,172.229996,172.229996,29517900\n', '2018-01-04,172.53999299999998,173.470001,172.080002,173.029999,173.029999,22434600\n', '2018-01-05,173.440002,175.369995,173.050003,175.0,175.0,23660000\n']

And let's do some string stuff ...
The first string backwards is 
emuloV,esolC jdA,esolC,woL,hgiH,nepO,etaD
  • File location: When opened, the name of the file can come in one of two forms:
    • "file.txt" assumes the file name is file.txt and it is located in the current program directory
    • (Windows) "c:\bill\file.txt" is the fully qualified file name and includes the directory information
    • (Mac) "/Users/donaldferguson/file.txt"

Writing Files

File Open Modes
  • Be very careful
    • Be careful if you open a file with the 'w' mode. It sets an existing file’s contents to be empty, destroying any existing data.
    • The 'a' mode is nicer, allowing you to write to the end of an existing file without changing the existing contents
  • If you are interacting with text files ("which is all we will do in this book"), remember that everything is a string
    • Everything read is a string
    • If you write to a file, you can only write a string
  • We may cover some binary files, and will give some details on what "everything is a string means."
  • Writing a file:
    • Once you have created a file object, opened for reading, you can use the "print" function
    • You add "file=filename" to the print command.
In [139]:
import time

f = open("/users/donaldferguson/tmp/message.txt","a")
t = time.gmtime()
t = time.asctime(t)
print("Writing the current time to the text file: ",t,file=f)
f.close()
  • All print() function calls have the parameter "file=..." If you do not include it, the default is stdout (aka "standard out."). This is the default output file, which is usually the terminal window.
  • When the program is finished with a file, we close the file
    • Flush the buffer contents from the computer to the file
    • Tear down the connection to the file (release the file for other programs)
  • close() is a method of a file obj
  • All files should be closed!

Structured Files and Streams

  • The most basic file types are text files and binary files.
  • There are many text and file types that use a pattern or schema for the text or binary file.
  • You have already seen one of these types -- CSV files.
    • A CSV file is a text file, but
    • The text follows a pattern
In [142]:
import json

courses = []

courses.append({ "title" : "Introduction to Databases", "number": "W4111" })
courses.append({ "title" : "Introduction to Computing for Engineers and Applied Scientists", "number": "E1006" })

print(json.dumps(courses, indent=4))
[
    {
        "title": "Introduction to Databases",
        "number": "W4111"
    },
    {
        "title": "Introduction to Computing for Engineers and Applied Scientists",
        "number": "E1006"
    }
]
  • Remember the terminal is "just another file." I can write the structured data to a JSON file.
In [143]:
import time

t = time.gmtime()
t =  time.asctime(t)

s = { "output_time": t, "courses": courses}

f = open("/Users/donaldferguson/tmp/some.json","a")
print(json.dumps(s, indent=4),file=f)
f.close()

Introduction to Exceptions

Overview

From Punch and Enbody, chpt. 6.

  • Most modern languages provide methods to deal with ‘exceptional’ situations
  • Gives the programmer the option to keep the user from having the program stop (die) without warning or explanation. The programmer codes the program to:
    • Retry failed condition.
    • Terminate gracefully and with an explanation.
  • "Again, this is not about fundamental CS, but about doing a better job as a programmer."
    • I strongly disagree.
    • This is fundamental. Software and programs are everywhere and critical.
    • Robust, reliable programs can be the difference between life and death.
    • This is what makes us engineers.
Weinberg's Second Law
  • What constitutes an exception?
    • There are many common ones that programs commonly experience
      • User enters invalid data.
      • Variable is wrong type.
      • for loop range index outside a list.
      • File not found on open.
      • ... ...
    • Developers can define their own exceptions to handle failures or errors in their application logic or input data.
  • Error and exceptions have specific names. You have seen many when your programs fail to execute. You have posted many of the errors on Piazza.
Error Names (Punch and Enbody)

Exceptions and Exception Handling

  • Basic idea:
    • Brackets and keep watch on a particular section of code
    • If we get an exception, raise/throw that exception (let it be known)
    • Look for a catcher that can handle that kind of exception
    • If found, handle it, otherwise let Python handle it (which usually halts the program)
  • For example,
    • We have assumed that the input we receive is correct (from a file, from the user).
    • This is almost never true. There is always the chance that the input could be wrong.
    • Our programs should be able to handle this.
  • "Writing Secure Code”, by Howard and LeBlanc, ISBN 978-0735617223.
    • “All input is evil until proven otherwise.”
    • Many security holes in programs are based on assumptions programmers make about input.
    • Secure programs protect themselves from evil input.

< DFF-Non-Textbook-Digression >

  • For example,
    • "Fuzzing or fuzz testing is an automated software testing technique that involves providing invalid, unexpected, or random data as inputs to a computer program."
    • "Fuzzing is used mostly as an automated technique to expose vulnerabilities in security-critical programs that might be exploited with malicious intent."
    • Both "good guys" and "bad guys" use fuzzing.

< /DFF-Non-Textbook-Digression >

In [19]:
%%HTML
<!-- HTML -->	
<div style="height:85px; color:red" class="example1">
<h3>Rule 7: All input is evil until proven otherwise.</h3>
</div>

Rule 7: All input is evil until proven otherwise.

Implementing Exceptions

Exceptions Form 1
  • try suite
    • The try suite contains code that we want to monitor for errors during its execution.
    • If an error occurs anywhere in that try suite, Python looks for a handler that can deal with the error.
    • If no special handler exists, Python handles it, meaning the program halts and with an error message as we have seen so many times
  • except suite
    • An except suite (perhaps multiple except suites) is associated with a try suite.
    • Each exception names a type of exception it is monitoring for.
    • If the error that occurs in the try suite matches the type of exception, then that except suite is activated.
In [17]:
# This program allows a user to input the radius on a circle.
# We want to teach the formula to young children. So, we only
# allow the radius to be an integer.

# Almost every program you write will use "programs" others have written.
# Your successful programs will become programs that others use.
# Any non-trivial program requires a team. The team members assemble
# the solution from individual subcomponents they build.
# The subcomponents and reusable parts are called modules.

import math     # We just imported our first module.

# Programs, like mathematical functions, are only useful if they
# operate on many user provided inputs. To start, we will get the input from
# the "command line."

done = False
error_count = 0
self_destruct = False

while not done:
    try:
        if self_destruct:
            x = 1 / 0
            
        # Print a prompt asking for the radius.
        # Set a variable to the input value.
        radius_str = input('Enter the radius of a circle: ')

        # We are going to do 'math' on the input. So, we should
        # covert it to an Integer.
        radius_int = int(radius_str)

        # The circumfrence is 2 times pi time the radius.
        # The area is pi * r squared.
        circumference = 2 * math.pi * radius_int
        area = math.pi * (radius_int ** 2)
        
        # Python conventions do not like lines that are too long.
        # \ means that we will continue the command on the next line.
        print ("The cirumference is:",circumference,  \
              ", and the area is:",area)
        done = True
    except ValueError as e1:
        error_count = error_count + 1
        if (error_count == 1):
            print("\nInvalid type. You need to enter an integer.")  
        elif error_count == 2:
            print("\nInvalid type. What part of integer did you not understand?")
        elif error_count == 3:
            print("\nSeriously? I cannot work like this. I am a professional.")
            print("Next time you do this I divide by 0!")
        else:
            print("\n Self-destruct sequence started.")
            self_destruct = True
    except Exception as e:
        print("\nException = ", e)
        print("Self-destruct complete.")
        break
    finally:
        print('\n Finally always called.')
Enter the radius of a circle: f

Invalid type. You need to enter an integer.

 Finally always called.
Enter the radius of a circle: f

Invalid type. What part of integer did you not understand?

 Finally always called.
Enter the radius of a circle: f

Seriously? I cannot work like this. I am a professional.
Next time you do this I divide by 0!

 Finally always called.
Enter the radius of a circle: f

 Self-destruct sequence started.

 Finally always called.

Exception =  division by zero
Self-destruct complete.

 Finally always called.

What Does This Have to Do With Files?

  • File not found is a very common error.
In [21]:
done = False

while not done:
    try:
        fn = input("Please enter a file name?")
        print("You entered ...", fn)
        f = open(fn,"r")
        print("\nReading file.")
        for s in f:
            print("A line = ",s)
        print("Done")
        done = True
    except FileNotFoundError:
        print("File not found. I will be patient.")
    except Exception:
        print("Something else happened.")
        break
    
Please enter a file name?f
You entered ... f
File not found. I will be patient.
Please enter a file name?/Users/donaldferguson/tmp/message.txt
You entered ... /Users/donaldferguson/tmp/message.txt

Reading file.
A line =  Writing the current time to the text file:  Sat Feb 10 23:21:50 2018

Done
In [4]:
%%HTML
<!-- HTML -->	
<div style="height:100px; color:red" class="example1">
<h3 class="example1">Reminder: Rules do far</h3>
</div>
<div style="height:100px; color:red" class="example1">
<h3 class="example1">Think before you program!</h3>
</div>
<div style="height:200px; color:green" class="example1">
<h3 style="color:green;" class="example1">A program is a human-readable essay on problem solving that also happens to execute on a computer.</h3>
</div>
<div style="height:150px; color:red" class="example1">
<h3 class="example1">The best way to improve your programming and problem solving skills is to practice!</h3>
</div>
<div style="height:150px; color:red" class="example1">
<h3 style="color:red;" class="example1">A foolish consistency is the hobgoblin of little minds</h3>
</div>
<div style="height:100px; color:red" class="example1">
<h3 style="color:red;" class="example1">Test your code, often and thoroughly</h3>
</div>
<div style="height:150px; color:red" class="example1">
<h3 style="color:red;" class="example1">If it was hard to write, it is probably hard to read. Add a comment.</h3>
</div>
<div style="height:150px; color:red" class="example1">
<h3 style="color:red;" class="example1">All input is evil, unless proven otherwise.</h3>
</div>
<div style="height:100px; color:red" class="example1">
<h3 style="color:blue;" class="example1">Don get's bored easily.'</h3>
</div>

Reminder: Rules do far

Think before you program!

A program is a human-readable essay on problem solving that also happens to execute on a computer.

The best way to improve your programming and problem solving skills is to practice!

A foolish consistency is the hobgoblin of little minds

Test your code, often and thoroughly

If it was hard to write, it is probably hard to read. Add a comment.

All input is evil, unless proven otherwise.

Don get's bored easily.'