Learn Python Quickly: My Crash Course in to Python Programming

Learning Python Quickly (How I did it!)

I had really been wanting to find a couple of hours to do a crash course on python and finally found an opportunity to do it last night.

Having been a programmer for a while, I’m finding many of the Python videos quite boring as they are for absolute beginners which has you plodding through the basics of programming which makes learning a new programming language painfully slow.

Luckily, I had found this great Python primer video by Derek Banas on YouTube.

I followed along and completed all the code in the video and had working examples of most of the important code snippets for much of how stuff gets done in Python.  Success was not without some pain, see problems and  resolutions below.

Video: Learn Python in One Video

I will save you some pain by telling you there is a very frustrating code issue at the end of this long video.

See code fix below.

When you are in the Dog class referencing the Animal super class from which it inherits the name, weight, height and sound, properties or values you have to use the setter and getter class methods instead of the object “self” reference like we could in the Animal object.  Once you change that, the code works.

For the Dog class, the toString() method only worked for me the example below:

(this works)
def toString(self):
        return "{} is {} cm tall and {} kilograms, says {} and owner is {}".format(
...instead of:
(this doesn't)
def toString(self):
        return "{} is {} cm tall and {} kilograms, says {} and owner is {}".format(

As a bonus I would add watching this video to help solidify the idea of polymorphism if you’re having difficulty getting a grasp of it.

Hope this helps someone!

Video: What is Polymorphism?

For Loops for Beginners – ASP, C#, PHP, JavaScript & Python Examples

A “For Loop” executes a block of code a specific number of times or while a specified condition is true.

PHP For Loop

for (init; condition; increment)
  code to be executed;


  • init: Mostly used to set a counter (but can be any code to be executed once at the beginning of the loop)
  • condition: Evaluated for each loop iteration. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends.
  • increment: Mostly used to increment a counter (but can be any code to be executed at the end of the iteration)

Note: The init and increment parameters above can be empty or have multiple expressions (separated by commas). Example The example below defines a loop that starts with i=1. The loop will continue to run as long as the variable i is less than, or equal to 5. The variable i will increase by 1 each time the loop runs:

PHP For Loop Example Code

for ($i=1; $i<=5; $i++)
  echo("The number is " . $i . "<br>");

Classic ASP For Loop Example Code

For i = 1 to 5
 Response.Write("The number is " & i & "<br>")

JavaScript For Loop Example

For i = 1 to 5
 Response.Write("The number is " & i & "<br>")

C# For Loop Example

for (int i = 0; i < 5; i++) 

Python For Loop Example

states = ["Alaska", "Alabama", "Arkansas"]
for x in states:
  if x == "Alabama":

Porting My Python 3 Scraper Script Over to my Kali Linux VM

I’m little further down the road in my training and want to take that Python Web Scraper script written on my Windows PC using Python 3 and run it on a Kali Linux VM which apparently is running Python 2.7.

My Original Python 2.7 Web Scraper Script

I fired up an old Kali VM that had my original python web scraper code and was able to publish it on my Github.

You can now get the original code and update it using the rest of this article.

So as with all things tech, it won’t run without some tweaking.

This is how I got it to work!

First, there is a difference in how you execute Python scripts in Linux. With Kali Linux, you seem to have several versions installed by default. Looks like python 2.7 is the directory where most of the goodies including the BeautifulSoup package my scraper needs were so I’m using this one.

Example of how to call python 2.7 then pass the script that is located in the “Desktop” folder to it.

The only code I had to update one line of  code and that was the reference to the urllib.

Why? Because the urllib and urllib2 packages have been split into urllib.request , urllib.parse and urllib.error packages in Python 3.x. The latter packages do not exist in Python 2.x

We are going backwards in version and

Old code: from urllib.request import urlopen as uReq

New Python Library Reference

from urllib2 import urlopen as uReq