Notes to help you quick start your experience with Cloud Storage, the Cloud IAM and Stackdriver.
Read MoreGoogle Cloud Platform (GCP) Essential Shell Commands
Google Cloud Platform (GCP) Essential cloud shell command lines. These are my notes from the GCP Essential Qwik Labs to help you get your VMs, health checks and load balancers up and running with GCP’s shell.
Read MoreIPND in Three Days or Bust - Wrapping up Project 2
Received my Project 1 submission at 1:09 am, but an little error on my part caused it to return. I tried to make on ordered list a child to a paragraph, and that is not allowed. Fixed a couple other things. The project is on GitHub at https://www.github.com/thechronicmonster if interested.
Sunday 7/19 9:58 am
Working on a procedure to decide if a day is a weekend or not. It looks something like this:
def weekend(day): if day[0] == "S" and day[-3:] == "day": return True else: return False
Using While Loops to create a countdown to blastoff:
def countdown(x): while x > 0: print x x = x - 1 if x == 0: print "Blastoff!"
Another solution to the find the biggest among three numbers is embed a function within a function (not quite recursive, these are two different functions).
def bigger(a,b): if a > b: return a else: return b def biggest(a,b,c): return bigger(a,bigger(b,c))
Today was derailed by a dehydrated bunny trapped in the garage. Thankfully the poor mammal decided to quit hiding and laid down near the doorway. I think we successfully nursed it back to its habitat, but the stress of seeing that little creature in such straights really capitalized my attention, today. Plus, the monster came back so once the bunny was satiated the monster became the center of attention. So, after an hour long bike ride/playground break and one and one-half gatorades I am now ready to take on Work Session 4 before calling it a night.
Time to work on creating a median finding function...
8:45 pm
It is now 10:51 pm and I have come up with a (probably terrible) solution to finding a median number given three numbers. So excited.
I started with the bigger and biggest functions and created mirrored smaller and smallest functions. My thought was if I don't know how to pick out the median I do know how to pick which numbers aren't the median. This works for three number medians. Once we take this problem to the next level my little solution breaks...but we're celebrating. The problem I ran into was when two of the inputs were the same so I created a function same that takes three inputs and checks if any inputs are the same and returns the double input. It looks like this:
def same(a,b,c): if a == b or a == c: return a if b == c: return b def median(a,b,c): x = smallest(a,b,c) y = biggest(a,b,c) z = same(a,b,c) if z != None: return z if a != x and a != y: return a if b != x and b != y: return b if c != x and c != y: return c if a == x and a != y: return a if b == x and b != y: return b if c == x and c != y: return c
Modular code: code that separates the data from its visual presentation such that one may be changed without effecting the other.
Best practices for writing code:
- Break a big task into smaller pieces
- use functions that have already been written
- write new functions to solve pieces of the bigger problem
- put the pieces together to solve the bigger problem
Systems thinking can be accomplished in a 5 step process:
- Understand the requirements of a problem. i.e. what are the inputs and what should the outputs be
- Plan an approach to solve the problem
- re-familiarize yourself with code that you've wrote so that it may be useful in solving the problem.
- Write new code to solve the other pieces of the problem
- Put all the pieces together.
IPND in Three Days or Bust - Project 2 Continued
Back from my break, enjoying Men Amongst Mountains by The Revivalists. Check them out on iTunes, buy their new album. Support great artists.
And we're back from our sponsors (joking). We left off with Work Session 3 and are now ready to jump into 2.4: Control Flow & Loops: If and While. Very important skills for the developer to have in her pocket protector...
6:52 pm
While loops operate WHILE a parameter is true. If statements run code depending on certain parameters. If statements are often united with if else and else statements.
If, else statements look something like this in Python:
if (some code here): print/return (or do something other than print) else: print/return (something else)
writing if functions to check for letters in strings and greater than/lesser than problems..and am now being warned of a Collatz conjecture problem. Sounds like a smart mathematician.
Remember when testing with booleans that True and False begin with capital letters..
7:28 pm
challenging quiz to create a program that will take three numerical parameters and output the biggest. Sounds like a fun challenge using if/else statements.
7:47 pm
I have grown greatly as a programmer in the past eight months. Solved what Dave classified as a gold star problem in ten minutes. So there's a word of hope for new programmers struggling through understanding. You will achieve your goals, even if it does require some amount of mental frustration.
8:22
Dave says that all programs can be wrote with arithmetic comparisons and functions (procedures) and if statements. That's quite a profound statement. There are other tools that make programming a bit simpler, I'm assuming, but what a statement to say these three things can accomplish all things in a program.
While loops syntax looks like:
i = 0 while i != 10: i = i+1 print i
Alright, wrapped up 2.4 and can now (technically) write any code in the world...I think it's true. I know just enough to be dangerous.
8:52 pm
Forward to 2.5: Debugging
Bugs, it's a programmer's life.
I'm not sure who's Andy's partner in Debugging, but he's a natural comedian.
Best explanation of Git I've ever heard: "Basically a big undo button."
Debugging strategy recap for those (me included) wondering what I've learned
- Examine error messages when programs crash (called a Traceback in Python)
- Work from example code (copy and paste what works and play till it breaks)
- Make sure examples work
- Check (print) intermediate results (remember to remove print statements after debugging)
- Keep and compare old versions (Use a VCS like Github for greater freedom in coding)
9:46 pm
That wraps up 2.5, Work Session 4 up next..
My brain has had it for awhile so that's it.
9:53 pm
IPND in Three Days or Bust - Project 2
Project 2 involves creating some Python code to generate html for me. This sounds exciting. I've only played around with Python a handful of times so this will be new territory for me. Very exciting!
11:22am
Python code is saved with the extension of .py
Running Python on a Mac is super simple. Open the terminal and type "python" press return and bam. Python running on the mac. To write code that you can save simply open your favorite IDE (I like atom 1.0 or sublime 3) and save your file with extension .py.
In Project 2 I'll learn how to use variables effectively and how to write functions to do repetitive work...we'll let's say review. I've been here before.
Informed it's time to clean the house...this may take awhile..
11:33 am
Back in the seat! 1:10 pm
Working through Introduction to Computer Science courses. I've taken this course in the past. Dave breaks down the basics into very simple concepts. In my experience, Udacity courses have been spot-on about 95% of the time.
Computers enable making repetitive steps at incredible speeds.
Some examples of the methods of thinkings:
Procedural thinking...follows instructions in code
Technological empathy as to how the computer interprets the code
Abstract thinking when conceptually understanding that a Python program, Python interpreter and web browser are different versions of the same thing (a program).
Natural languages can be full of ambiguity and verbosity. Computer programs must be precise and concise. This is why computer languages exist and computers do not operate in English or Mandarin or some other human language.
However, Python and other programming languages have grammar rules that must be followed. We call that syntax.
Backus-Naur Form helps humans write in language that computers can interpret.
Expression is something that has a value. Python follows the grammatical structure of Arithmetic expressions is Expression Operator Expression
On to Stage 2: Work Session 1
1:36 pm
Pulled away again right after last post...Back on for another three hours of uninterrupted study time. Had to pick up The Revivalists new Album Men Amongst Mountains, first though. Just released yesterday. I've been listening to these guys nonstop and have to support them on their debut weekend.
Back to the Mighty Python...3:27 pm
Wrapped up 2.1 and the work session 1 with some syntax quizzes in Python. Moving on to 2.2 Variables and Strings
So, now we're talking about variables. A Variable is an assigned expression that can be changed.
An Assignment Statement i.e. Name = Expression, assigns an expression to a variable.
Moving on to strings. Strings can be printed using " " or ' ', double or single quotes. Strings can be concatenated with the operator +.
Strings can be sequenced using square brackets [].
Strings are 0-based so that the first letter begins at the number 0 and moves forward from there. For example:
name = JP print name[0] will print J
You can also print a range of letters using the colon : as in
print word[3:6] this will print the fourth to the sixth letters in the word. Remember, strings are 0-based so the first letter is counted as zero. Negative numbers can be used in the square brackets. Negative numbers count from the end of the string.
Words in strings can be found using the method .find.
string.find('word-in-string') will print the character at which the search term begins.
A return of -1 means that the string was not found.
Strings are case sensitive.
4:05 pm
More vocab:
Parameters are values or numbers that go inside parentheses. Parameters can help you find specific points within a string...in the case of finding strings. They have other uses too..Specifically with the .find method the first parameter will be a letter or phrase and the second parameter can be a number. This number tells the method at which character it should begin looking for the first parameter.
Wrapped up 2.2 looking at how these parameters effect strings.
4:17 pm
On to Stage 2: Work Session 2..
Apparently triple double or single quotes can be used to print multiple line strings. That's a new one for me.
Work session 2 involves some fun string .find-ing quizzes
5:02 pm
2.3 moves on to Functions (or procedures). I am constantly misspelling function...not good when working in object oriented programming.
Python functions are linked to the keyword "def" and "return" breaks the function and computes a result..parameters here are called inputs, sometimes parameters are also called operands.
I'm thinking that def stands for defined. So, function defined as...
syntax of a python function looks something like
def functionName(parameter): return parameter do something print functionName(value of parameter)
Finished up 2.3 and will go through the next work session before taking a short break.
5:41 pm
The final quiz begins walking your through the process of using Python to create HTML. This is going to be really cool, and it's a skill I can't wait to master. Absolutely brilliant to write a program to create more programs for you. I suppose, though, that this is the idea behind AI technology. Create the AI program and it can create on it's own...but that is for another course, and one that is available on Udacity, as a matter of fact. But that's all for me for about an hour or so.
5:57 pm