Python: Tony Gaddis

pythonBook

## Learned

########################

First off, it was stressed that the point of this class was first and foremost Programming Fundamentals, not becoming Python experts. I loved this approach personally, and it’s not like we are not learning a ton of syntax and logic going through the motions anyhow. Our first file was a simple one ( this was of course after the initial Hello World start which can be as a simple print statement, i.e., print(‘Hello, world!’) ), ask a user for their last name.

My takeaway from this a few things: what the hell is a variable, that must be a statement that displays something, yay it worked, and that calls the variable like that after storing some input, hmm, sweet, a lot going on there from a beginners perspective, but cool!

Afterwards, we went through quite a few whiteboard exercises and flowcharting. Picked up a version of Microsoft’s Visio (thank you student perks and discounts!) to do the diagrams.

This slideshow requires JavaScript.

It helps! Being able to structure out your program before writing any code logically seems like a no-brainer, but sometimes people take planning for granted. Then just jump right into barreling through the design process before attempting to find pitfalls ahead of time.

The next thing we went through was a program that follows one of the flowcharts we made for tip, tax, and charge. Played with different errors to get used to seeing them and went ahead and practiced some more equations, as well.

Learning how to comment a program you are writing, I think, is an essential skill for future proofing what you’re doing. I’ve already gone back just a couple months and have forgotten just what I was trying to attempt and had to relearn my logic or algorithm just to be able to edit it properly. Obviously, this will get easier with time, but proper commenting has been a lifesaver. Comment!

## Chapter 2

########################

Progressing! Some more equation practice, well kind of, more like just a math problem, but it also incorporates learning about the difference between int and float, and some more user input.

A means to an end, or just an average beginning? Haha, yup, made myself laugh, take that. Get some info now!

Getting to the gritty now, knowledge is power, and if you know your base, you can keep them informed or ‘in the know.’ Now we can contact them! Let’s practice that formatting!

Well, nice to meet you, Mr. ‘.2f‘. I have to say that this formatting stuff has been needed in 99% of all my programs since, most definitely a good trick to get your head around for now when dealing with float returns. Hot dogs, anyone?

Why do the math when you can just make your own program to do the math for you from here on out. Now, to implement this into my Alexa, and now she can tell me all about the dogs, wait, she probably already can, “Alexa, import math?”

Well, well, well… got a bit more involved on this one. Financial programming can definitely be helpful to a lot of people. I don’t know about you, but I’d rather trust a pre-written formula than doing the math myself.

## Chapter 3

########################

Went for a leap! Practiced a bit more formatting design with this one. Division and modulo spectacular. Now there are a few mistakes as I look back on this one. Some redundant or unnecessary code, but it still worked!

leapDay

What I found interesting about this one was really getting a handle on the modulo operator and it getting the remainder of a division problem and using it as a Boolean.

Speaking of modulo fun, Easter has an equation that was pretty tricky to get my head around.

easterPic

Now there were a few exceptions we had to account for with this specific problem, the exception years of ’54, ’81, ’49’, and ’76 which apparently factor a week late on the Easter date.

Now the ultimo calculator type we were to build in a homework exercise was this thing called Zeller’s Congruence, which is an algorithm developed to calculate the day of the week. The formula for this is:

zellerCongruence

Taking into account:

zellerCongruencerules

This had to be put into code which I translated into the following:

This one really helped get your head around some more complex equations for algorithms using the Python syntax.

zellerCongruencePic

Programming is much more useful than creating a bunch of calculators, but I think getting your head around things like binary, algorithms, and learning how computers compute is invaluable to learning logic.

Two last calculators, we had to build were a distance converter and a converter that would convert some days into weeks and days.

distanceConverter

Keeping the output basic, we are just focused on getting down the syntax.

## Chapter 4

########################

Tables! Where would we be without a couple good ol’ tables? This one’s chilly. Had a chance to play with some more formatting and loops. Don’t know where I’d be if it weren’t for a good loop.

The above produces the output:

windChill.PNG

If there’s one thing in life that’s constant it’s… CONSTANTS. Get it? Ha… haha, yeah here’s some code for that. =D

There was also some sentinel talk. You know, the Sentinel that forever was doomed to watch unmoving, with inaction, but forced to still observe. Oh no, not that one, just a this one:

Fractional value. I really enjoyed getting to know about accumulators, and ranges implemented into a loop. There are so many different directions that you can take these concepts.

Who likes to calculate anyway? Seriously, though, these bite-sized programs are the part of a bigger picture that can produce a product. Here’s another table!

tempConvert

…and the code.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s