Python Video Course for Beginners


Python For Beginners Video Course with Practice Sheets

This introduction to the Python Programming Language is directed by Jason Cannon.

MP4s open in new window. You can also Right Click and Save Link As.

Python Setup

python 2 versus 3 You should use Python 3.x stable. If you need components not available in 3 then using v2.7x is recommended.


python integrated development area Python Integrated Development Environment or IDLE is pre-installed so you can create or edit software.


python linux install Install Python 3 on Linux by typing sudo apt-get install -y python3 idle3 in your Python 2 IDE or terminal.


python mac install Install Python 3 on Mac by heading to python.org and downloading the latest Mac OS X stable version.


python windows install Install Python 3 on Windows by heading to python.org and downloading the latest Windows stable version.


python 2 versus 3You can run your program from the command line instead of loading it into IDLE each time you wish to use it.


For an OS not listed above please use this link to see if yours is supported.


Strings and Variables

python variables and strings Variables are storage locations that have a name or name value pairs. You can assign values to a variable and recall those values by the variable name.


python functions and printing Functions are sections of reusable code that perform actions. When a Value is provided as an Arguement to the Print Function it displays that Value to the screen.


python string methods Everthing in Python is an Object. Every Object has a Type. 'apple' is an Object of type "str". 'apple' is a String Object. fruit = 'apple'. Fruit is a String Object. Methods are Functions run against an Object. object.method❨❩


python strings and concatenation To Concatenate or combine 2 Strings we use the + sign. You can Concatenate multiple strings by using additional + signs and strings.


python formatting strings We can call the Format method on a String instead of Concatenating. Create placeholders by using curly brackets { } in the String, and pass in Values for those fills to the Format Method.


Numbers and Math

python number, numeric ops and functionsNumbers in Python require no special treatment. To use a Number simply include it in your Source Code. To assign a Number to a Variable use the: Variable Name = Number


python comments Comments are notes you leave within the source code during software development. Using the pound key aka hash tag:
# write your comment on a line separate from your source code


Boolean and Conditionals

python booleans Booleans are data types that can only have TRUE or FALSE values. We use a_boolean = True to assign a boolean to a variable without using quotes around True or Flase.


python conditionalsThe if statement evaluates to a boolean expression. If True, the associated code is executed. E.g. if 37 < 40 - Since boolean expression 37 less than 40 is True - print ('Thirty-seven is less than Forty.'); - if statement is executed.


History: Boolean Data Type


Functions

python functions part 1 Functions allow you to write a block of Python code once and use it many times. When you need to execute the same task over again call the Function containing that code.


python functions part 2 The first statement of a Function is a Documention String or Doc String. Surround text with Triple Quotes which provides a summary of the Function.


Lists

python lists Lists are data types that hold an ordered collection of items, which can be various data types or even lists of lists.


python slices Slices are portions of a List. To access a Slice specify 2 indices separated by a colon within brackets. E.g. list [index.1:index2] or list [:index2] or list [index1:]


python loops for Loops are used to perform some kind of action within a list.
E.g. for item_variable in list_name: followed by a # Code block


python sorting ranges To sort a List call the sort list method on the list with out any arguements. This will re-order the current List. To create a new List use the built in sorted Function and supply a List as an arguement.


python exception handling The index List method accepts a value as a parameter and returns the index of the first value in the List.


Dictionaries

python dictionaries one The Dictionary is a data type that holds key-value pairs called items. They are also known as associative arrays, hashes, or hash tables.


python dictionaries two One format for Looping through items in a Dictionary is for key_variable in dictionary_name:. The code block that follows the for statement will be executed for every item in the Dictionary.


Tuples

python tuples Tuples are immutable Lists. They Can Not be changed once defined. You can Add, Change or Remove the Values in normal Lists. Tuples you Can Not. Tuples like Lists are Ordered and Values in the Tuples are accessed by Index.


Files

python files one If you want to keep data generated by a program you need a place to store it. Files are great for storage that lasts beyond the execution of a program. To retrieve that data you will need to use certain techniques.


python files two When you are done with a File you will need to close it. If many Files are opened during execution you will get the Too Many Files Open Error.


Modules

python modules one Module files end with the .py extension. They can implement a set of attributes (variables), methods (functions), and classes (types).


python modules two Python has a large library of Modules. Before writing your own code it best to look through the Python Standard Library. Modules like CSV, logging, urllib.request, and json have already been established to save you from trying to reinvent the wheel.


Infographic: Common Python Mistakes