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.
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:
- Contains constants for 551 named colors* (e.g, as named tuples:
Color = namedtuple('RGB','red, green, blue')
- Extends the
Color class to include a method for getting the hex formatted color:
- Stores these constants in an
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 »
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.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 »
In this short video, I show you how to reverse a string using slicing in Python: Read the rest of this entry »
We’re working on some new Python courses and, although students will be able to use their IDE of choice, we plan to use IDLE as the default editor. To make it easier to open files directly into IDLE from Windows Explorer, I associated Python files with IDLE. As IDLE doesn’t come up as one of the default options for editing Python, it’s not as intuitive as it might be, but it’s pretty simple. Here’s how you do it: Read the rest of this entry »