Advanced Python

In this college-level course trainees become proficient in Object-Oriented Programming in Python, and they become familiar with selected advanced concepts including ternary operators, anonymous lambda functions, filters, maps, decorators, JSON, XML, and the basics of working with data.

Note: This course is only available as part of NCLab’s Python Developer Career Training program. Click here for more information.

Course Features

  • Trainees learn at their own pace by reading tutorials, watching videos, going through examples, and solving programming challenges.
  • Every short lesson is followed by self-assessment, so that trainees instantly know whether they have mastered the concept.
  • Trainees obtain real-time help from the NCLab AI tutorial engine, as well as remote assistance from live course instructors as needed.
  • The course incorporates fundamentals of Computer Science which every software developer should know.
  • Trainees learn how to use powerful Python libraries including Matplotlib, Numpy and Scipy.
  • An interactive Python coding app allows trainees to create portfolio artifacts and easily share them online.

Prerequisites

This course has Python Fundamentals as a prerequisite.

Equipment Requirements

Internet access

Email

One of the following browsers:

  • Google Chrome
  • Mozilla Firefox
  • Microsoft Internet Explorer (9.0 or above)
  • Safari

Course Structure and Length

This course is self-paced, and trainees practice each skill and concept as they go.  Automatic feedback is built into the course for both practices and quizzes.

The course is divided into four Units, and each Unit is composed of five Sections. Each Section consists of 7 instructional/practice levels, a quiz, and a master (proficiency) level. Trainees can return to any level or quiz for review.

This table illustrates the course structure as units, sections, and levels.

While learning skills in the Advanced Python course, trainees can practice writing code, work with libraries and create portfolio artifacts with NCLab’s Python app.

Advanced Python is designed to take approximately 80-120 hours. Since the course is self-paced, the amount of time required to complete the course will vary from trainee to trainee. Trainees are responsible for learning both the tutorial content and the skills acquired through practice.

Unit 1 (Programming Practice and Review)

While writing Python programs, trainees learn how binary computers work, including binary and hex numbers, logic gates, logic circuits, binary adders and multipliers. They implement a model of a binary computer in Python.

Section 1

  • Understand why decimal numbers are natural for humans, but binary numbers are natural for computers.
  • Know that binary numbers consist of zeros and ones.
  • Count in binary.
  • Know the different types of variables, such as integer (int), real number (float), text string (str) or a list (list).
  • Check types of variables using the built-in Boolean function isinstance().
  • Generate random integers using the function randint() from the random library.
  • Generate random binary numbers.
  • Convert decimal numbers to binary.
  • Convert binary numbers to decimal.
  • Review adding positive integers using the pencil-and-paper method.
  • Add binary numbers in base 2.
  • Know that computers first convert decimal numbers into binary, then process them, and then convert the result back into decimal again.

Section 2

  • Know the meaning of bits (b), Bytes (B), and many other units of data size.
  • One bit (1 b) represents the smallest amount of information – two objects or states such as True or False, 1 or 0, etc.
  • With N bits one can represent 2**N objects. For example, with 8 bits one can represent 2**8 = 256 objects such as text characters.
  • 8 b = 1 B, 1024 B = 1 KB, 1024 KB = 1 MB, 1024 MB = 1 GB, 1024 GB = 1 TB etc.
  • Units such as Bytes (B), Kilobytes (KB), Megabytes (MB) etc. are mostly used for the size of stationary data.
  • Know what amount of data these units can roughly represent.
  • Units such as Kilobits per second (Kbps), Megabits per second (Mbps) etc. are used to indicate speed of streaming data.
  • Use the ASCII table to represent text characters.
  • One ASCII character is represented using 8 bits (1 Byte).
  • The ASCII table contains 256 characters.
  • The first 32 ASCII characters are control characters and the last 128 are other special non-printable characters.
  • There are 95 printable characters that begin with the empty space (code 32).
  • Obtain the ASCII code of a given text character using the function ord().
  • Obtain the text character for a given ASCII code using the function chr().
  • Implement and use the famous ROT13 cipher. The ROT13 cipher is special because it can be used for both encryption and decryption.
  • Use the ASCII table to convert a text string into a binary stream and vice versa.
  • Add (concatenate) text strings on the binary level.

Section 3

  • Work with hexadecimal (hex) numbers.
  • Know that one hex digit ‘0’…’F’ corresponds to decimal 0…15.
  • Count in the hexadecimal system.
  • Know that two main applications of hex numbers are representing locations (addresses) in computer memory and colors.
  • Check whether a given item is present in a list.
  • Use the ASCII table when generating hex numbers.
  • Convert decimal numbers to hexadecimal.
  • Convert hexadecimal numbers to decimal.
  • Uppercase hex numbers before working with them, because they may contain both lowercase or uppercase characters.
  • Know the special relationship between hexadecimal and binary numbers. More precisely, that one hex digit exactly corresponds to four binary digits.
  • Convert hex numbers convert to binary one digit at a time.
  • Convert binary numbers to hexadecimal in four digit chunks.
  • Use Exceptions to check the correctness of input data in functions.
  • Sometimes these sanity checks can take more lines than the actual function body – that is perfectly OK.

Section 4

  • Learn about transistor count, Moore’s Law, and CPU clock speed.
  • Explore transistors and logic gates.
  • Use Python to simulate the basic seven types of logic gates AND, OR, NOT, NAND, NOR,  XOR, XNOR.
  • Practice safe programming with Exceptions

Section 5

  • Use the logic gates to build the Half Adder, and understand that it represents a fundamental connection between logic and arithmetic.
  • Build different adders and multipliers, including:
    • Full (1-Bit) Adder using logic gates.
    • Full Adder using two Half-Adders and one OR gate.
    • Ripple Carry Adders by stacking Full Adders into arrays.
    • Two-Bit, Four-Bit, and Eight-Bit Adders.
    • Multiply binary numbers by combining the shift and sum operations.
    • Four-Bit Multiplier (FBM).
    • Decimal multiplier based on the FBM.

Unit 2 (Object-Oriented Programming I)

Trainees learn basic concepts of Object-Oriented Programming (OOP) including class, object (instance), attribute, and method. They design numerous classes of their own, and gain a solid practical experience with OOP in Python. They validate their knowledge by implementing their own version of Python Turtle Graphics.

Section 6

  • Brief history of computers and programming languages.
  • Importance of using well-designed data structures.
  • How did object-oriented programming evolve from procedural programming.
  • Main differences between procedural and object-oriented programming.
  • Classes consist of data (attributes) and functions (methods).
  • An object is an instance of a class.
  • A class can have many different instances.
  • Instances of a class do not share data.
  • Methods are defined on the level of a class but used on the level of an instance.
  • All data types in Python are classes.
  • The so-called “magic methods” in Python and how they work.
  • The bitwise operators  &  (AND) and  |  (OR).

Section 7

  • Define new classes using the keyword class.
  • Use the constructor __init__() to define class attributes and initialize their values.
  • The constructor as well as all class methods must have a mandatory first parameter self.
  • All attributes and methods of a class must be accessed through the prefix self.
  • Add new methods and new attributes to a class.
  • Instantiate a class.
  • It is a good programming practice in OOP to always access class attributes via class methods (not directly).
  • Use the Sympy and other Math libraries.
  • The name ‘self’ is not a Python keyword.
  • Create two training classes Vocabulary and Number.

Section 8

  • Defining new classes using the keyword class.
  • Using the constructor __init__() to define class attributes and initialize their values.
  • Adding new methods and new attributes to a class.
  • Instantiating a class.
  • Using file operations and working with regular expressions.
  • Not every class needs to have attributes.
  • When a class does not have any attributes, it does not need a constructor.
  • Create two new classes Converter and DataMiner.

Section 9

  • Students implement class Line to represent lines in the XY plane:
    • Attributes: startx, starty, angle, length, lw (line width), color, ls (line style).
    • Methods: __init__(), get_endpoint(), set_endpoint(), plot(), get_length(), get_area().
  • Make data structures flexible and open to future development, even though this can mean that they require more memory.
  • Premature optimization is the root of all evil (or at least most of it) in programming.
  • Four line styles in Matplotlib and how to use them.
  • Objects can be stored in lists as any other variables.

Section 10

  • Students use the class Line as a basis to implement class Turtle, a simplified version of the well known Turtle Graphics program in Python:
    • Attributes: posx, posy, angle, linewidth, linecolor, linestyle, drawing, lines.
    • Methods: __init__(), go(), left(), right(), penup(), pendown(), goto(), back(), set_angle(), show(self), width(), color(), style(), get_length(), get_area().
  • Practice working with exceptions.
  • Additional useful functions of Matplotlib.

Unit 3 (Object-Oriented Programming II)

Trainees learn advanced concepts of OOP including inheritance, class hierarchy, polymorphism, and multiple inheritance.

Section 11

  • Static methods and when they can be used.
  • How to derive a subclass from a superclass.
  • When a subclass should be created, as opposed to modifying the original class.
  • If the superclass has any attributes, then the constructor of the subclass must call the constructor of the superclass.
  • Using the function super() to access the superclass.
  • Subclasses can add new attributes and methods, as well as override methods.Importance of a well-designed class hierarchy.
  • What is polymorphism and when it can be useful.
  • What are abstract methods and abstract classes, and when they should be used.
  • Using the abc (Abstract Base Classes) package to facilitate working with class hierarchies.
  • Using ternary conditional expressions of the form val1 if boolean else val2.

Section 12

  • Programming practice: Upgrade the Graphics Editor from Python Fundamentals to an object-oriented design (Phase 1).
  • Design a base class Shape with 6 attributes and 20 methods.
  • Meaning of single and double underscores in the names of class attributes and methods.
  • Review: PEP 8 – Style Guide for Python Code, copying lists via slicing, list comprehension, shallow and deep copying, obtaining memory addresses of Python objects, accessing class attributes via dedicated class methods.

Section 13

  • Programming practice: Upgrade the Graphics Editor from Python Fundamentals to an object-oriented design (Phase 2).
  • Design and implement a hierarchy of 10 classes to represent basic geometric shapes.
  • Practice class creation and inheritance.

Section 14

  • Programming practice: Upgrade the Graphics Editor from Python Fundamentals to an object-oriented design (Phase 3).
  • Design and implement class Figure to represent figures consisting of one or more basic shapes.
  • Practice class creation and inheritance.

Section 15

  • Programming practice: Upgrade the Graphics Editor from Python Fundamentals to an object-oriented design (Phase 4).
  • Design and implement three different classes SimpleDrawing, SmartDrawing, and TechDrawing based on three different use cases.
  • Analyze an example of bad object-oriented programming.
  • Understand that in OOP, classes should always work with their own attributes.
  • Multiple inheritance, it’s applications, and its limitations.
  • Multiple inheritance vs. standard inheritance.
  • The Diamond Problem and when it represents a real problem.
  • Mixin classes.

Unit 4 (Working With Data)

Trainees learn how to use powerful Python libraries Pandas, Seaborn and Statsmodels to perform elementary operations with data.

Section 16

  • Importing the Pandas, Seaborn and Matplotlib libraries.
  • Understanding Pandas DataFrames.
  • Entering data into DataFrames.
  • Using the regression line to make predictions.

Section 17

  • Reading files from the hard disk or from a URL.
  • Obtaining the number of rows and number of columns of a DataFrame.
  • Obtaining the list of all column names of a DataFrame.
  • Displaying the beginning and the end of a DataFrame.

Section 18

  • Calculating the minimum, maximum, sum and mean of column values.
  • Calculating variance and standard deviation.
  • Plotting histograms with Pandas.
  • Displaying boxplots with Seaborn, and how to interpret them.

Section 19

  • Correlation and the Pearson coefficient (R-value).
  • Visualizing correlation graphically via heatmaps.
  • Understanding the purpose of using the R-squared value, and its advantages over the R-value.
  • Calculating the R-squared value by squaring all values in the correlation matrix.

Section 20

  • Quantifying the results of linear regression analysis.
  • Statistical hypothesis testing.
  • Multiple linear regression.
  • Logistic regression.