Webucator blogs about online learning and training.

Webucator Blog

In this short video, I show you how Python os.renames() method works: Read the rest of this entry »

In January, I created a video showing how to use FileDrop.js and Papa Parse to convert between CSV and JSON. Someone asked me for the files I used in the demo, so I’m adding them here in case are interested too. Read the rest of this entry »

In October 2014 we announced that we would offer a scholarship to support a student who shows potential for leadership in the field of Computer Science. We were happy to find that there was a lot of interest in the scholarship and we are even happier to award it to Jared Beach, a student at the University of Alabama. Jared’s essay explaining how he plans to use computer science in his career set him apart from the other applicants.

Jared, congratulations! You are the recipient of Webucator’s $1,000 Computer Science Scholarship for the 2015-16 year! Computer science is an exciting field in which we think and hope you will have an exciting career!

Webucator’s Computer Science Scholarship is awarded annually to a student who shows potential for leadership in the field of Computer Science. The deadline to apply for the 2016-2017 academic year is March 31, 2016.

LXML is a “Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.Read the rest of this entry »

For Pygame and other graphics work, it’s helpful to have color constants that hold the color RGB values. I couldn’t find anything like this, so I created a color_constants module that:

  1. Contains constants for 551 named colors* (e.g, as named tuples:
    Color = namedtuple('RGB','red, green, blue')
  2. Extends the Color class to include a method for getting the hex formatted color:
    class RGB(Color):
        def hex_format(self):
            return '#{:02X}{:02X}{:02X}'.format(self.red,self.green,self.blue)
  3. Stores these constants in an OrderedDict.

The colors are shown in the table below and the full code is shown below that. Read the rest of this entry »

I’m not a game developer, but I’ve been playing with Pygame lately and have been impressed. I plan to use it in one of our Python courses to teach object-oriented programming. I use 64-bit Windows 8, so I have the 64-bit version of Python 3.4. Most of our students are unlikely to be game developers, but because games have obvious visible objects, they provide a nice framework for teaching OOP.

Unfortunately, Pygame doesn’t have an official 64-bit installer, so they recommend you use the 32-bit version of Python. So, I installed the 32-bit version of Python alongside the 64-bit version I already had, but that was a pain as I had to constantly make sure I was running the right one. It also made the 32-bit version the default.

Luckily, Christoph Gohlke of the University of California, Irvine has made a bunch of 64-bit binaries available for Python extension packages, including one for pygame. Read the rest of this entry »

In working on the math lesson of an upcoming Introduction to Python 3 course, I was trying to come up with a use case for math.isnan(x). I’ve used isNaN(x) in JavaScript as a simple check to see that a user entered a number. Here’s a simple illustration: Read the rest of this entry »

The Python documentation on pow() states that pow(x,y,z) is computed more efficiently than pow(x,y) % z, but our tests don’t show that to be the case. In fact, we found x**y % z to be the most efficient way to complete the operation. Note that this is academic as all the methods we tested for raising one number to the power of another and then doing a modulus operation are lightning fast. You should use whichever method suits your coding style the most, but for those who are curious, here’s how we tested it: Read the rest of this entry »

Let’s say we have two scripts: foo.py and bar.py.

They are exactly the same. They begin with the definition of a function called main(), which simply prints out the value of __name__, a built-in variable that returns the name of the module. Read the rest of this entry »

The difference between str.isdigit() and str.isdecimal() in Python is, for most of us, academic and can be used interchangeably. According to the Python documentation, the decimal category “includes digit characters, and all characters that can be used to form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.” Read the rest of this entry »

© Webucator, Inc. All rights reserved. | Toll Free: 877-932-8228 | Outside the USA: 315-849-2724 | Fax: 315-849-2723