Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Monday, July 13, 2026

CSTA 2026 Day One

CSTA 2026 didn’t start until noon today so I spent some time exploring. I wandered around the French Quarter. Bourbon street is not the same at 8AM as it is at 8PM for sure. But I found some good food and am snacking on a beignet as I write this up.

I snuck into the exhibit hall before it opened to take pictures of some of the booths. They’ll probably wind up in a blog post after the conference. While snooping around I was able to talk to one of the outstanding people in computer science in education -  Mitch Resnick from the MIT Media Lab.

I took a workshop with him about Scratch a number of years ago. He was nice enough to let me get this picture. Mitch is the person behind Scratch and Octostudio. I was able to talk to Mitch for a bit which was great. We talked about tools with low floors and high ceilings. We also talked about letting students get creative and have fun while learning..

Getting to talk to people is one of the best things about CSTA! I have connected with many friends and talked to a lot of new (to me) people. That’s been great

I went to a couple of sessions. I spend half of an hour with two physical computing . One of the Robolink Codrone and one on Micro Bits. Both are interesting. Drones are more expensive but I think they may attract some students that micro:bits might not. I was looking for a bit more innovation because I have seen both of these before. I’ve owned and used micro:bits as well. I think that these session were very good for people who are not as aware of these tools. I do think they are both pretty cool. If you have the money for them I can see them driving interest.

Next up for me was a session on MakeCode Tutorial Editor. This one was very good. It was hands on and the handout has an exceptional number of useful links. The Tutorial Editor allows a teacher to create their own tutorials for students to use to learn hands-on with MakeCode. We did some work in the session using AII tools to write the tutorials. I’m pretty sure I want to learn more about creating tutorials “by hand” though.

BTW MakeCode and its variants is a development environment that allows students to program with blocks, JavaScript, and Python for small arcade devices, micro:bits, and more. If you haven’t checked it out yet your really should.

The opening keynote was pretty good. I was mostly interested in Jake Baskin’s part of it though. He’s the Executive Director of CSTA and he talked about the state of the association. I need to think about some of it to see if there are places for me to get more involved. One highlight was his talking about a new definition of computer science. Always good for a discussion. Anyway, it is:

Computer science is the study and human-centered practice of using data, algorithms, and computing systems to solve problems, make discoveries, and express ideas.

Jake emphasized the term :human-centered.” I really like how he made the case that students need to learn computer science, perhaps even more so, in the age of artificial intelligence. I expect to hear more about the future of CS education from more people over the next several days.

Thursday, August 14, 2025

Reading Code For Fun and Learning

For some time I have been writing up information about some historic, and simple compared to modern, cryptonymic algorithms. They are collected in book form (a PDF actually – new release coming soon) that I have made available on my website. One algorithm that I have struggled with has been the Playfair Cipher. I don’t know why but for some reason I’ve had trouble with the algorithm. Mostly, I have struggled with how to code it up. Recently, I decided that I should work on that.

First step was to use something called Notebook LM. More on that in a future post. It’s pretty amazing. In any case, that tool helped me find a coded implementation of the Playfair Cipher. Great! Maybe I can learn from that. It turns out that I can.

The code was in Python and I am not very experienced with Python. Still with well over a dozen languages under my belt, figuring out the code was not hard. After reading the code I feel like I have a better handle on things.

I also learned more than I expected about how Python does things. So double the win. I do believe that reading code is a great way to better understand a programming language. It’s especially valuable if it helps you learn the idiom of the language.

So I now had a console application that worked and that I could play with. Now to me, a console application is so late 20th century that my next step was to convert to C# so I could use Windows Forms. Since I was already using “artificial intelligence” (that’s in quotes because I don’t completely buy that these tools are actually intelligent.) I asked Copilot to convert the Python code into C#. It did so quickly and easily. It wasn’t the way I am used to doing things though. Maybe that is why I was struggling with my own code? It’s a possibility.

The old joke is/was that a good FORTRAN programmer can write a good FORTRAN program in any programming language. Apparently, Copilot can write a good Python program in C#. Yes, the code looked a lot more like the Python code than I had expected. More than I really wanted as well. But along the way I learned that C# could do some things in some ways that I didn’t realize. There have been a lot of changes and updates in the language and I have clearly not kept up with all of them. Well, more learning is a good thing I guess.

Once I had the converted code I built a nice Windows application and have had some fun with it.

I am toying with messing with the C# code to make it look more like what I am comfortable with but that may not be the best use of my time. I might be better off experimenting with the new (to me) features of the language. Either way, learning is a good thing.

Friday, March 07, 2025

Rethinking High School Computer Science

I love programming. I took a computer science course as an undergraduate and really fell in love with programming.While I made my living writing code for many years, my wife once wondered if I would have been happier with coding as an avocation rather than a vocation. That’s a bias I have no doubt taken in my teaching career. But is it the right bias for developing high school CS curriculum? I’m starting to wonder about that.

I’ve said in a number of ways that we don’t teach high school physics because we need for physicists. We teach HS physics to help students understand the world they live in. The same needs to be true for high school computer science.

A recent blog post by Mark Guzdial brought that into focus. (CS doesn’t have a monopoly on computing education: Programming is for everyone) The key line in that post was this: Computing education for non-CS majors is different than what we teach CS majors.

Now we talk a lot about computer science for all and that teaching high school computer science should not be about vocational training or just preparing students to be CS majors. But is that how we are developing our curriculum and our ideas about what students should be taught?

Note: The rest of this post is based on a comment I left on Mark’s blog post BTW.

Often we're lucky to have any CS courses even with improvements in recent years. SO having a variety of courses for different types of students seems impractical. High schools don't have the resources that universities do. Actually, small colleges and universities don't have the resources that schools like Michigan does!

But circling back to high schools which is my focus, what should we be teaching? For the most part, high school CS is largely still preparation for CS majors in university or for vocational preparation. The growth in cybersecurity courses in indicative of the vocational focus, for example.

Some schools do have the ability to offer multiple courses. It takes a larger CS program to do that though. The high school I retired from did adopt a course teaching Python largely at the request of the Physics department, for example. R is a big language in many university majors but we don’t see much R in high schools. Should we? I am not sure. Many schools will be limited to one or two courses that have to prepare everyone in any case.

Advanced Placement Computer Science Principles is probably the closest course available for computing education for meeting multiple computing paths. It's still controversial in HS CS with its perception in some circles as a watered-down CS course. It may just be the course we should be paying the most attention to though.

Writing requirements for HS CS is going to remain difficult though. Getting people to give up or even depreciate loops is going to be impossible. (Reading the Guzdial post makes that last line more understandable. Not all programming requires loops.)

Ultimately, high school computer science is all over the map from schools that offer little to none with few taking CS to schools offering multiple options and requiring all students to take some. Universities cannot expect students to have even a base level of CS. Some students are going to have huge advantages. And that makes me sad.

Saturday, December 17, 2022

Coding with ChatGPT–Armstrong Numbers

Trying out ChatGPT seems to be all the rage these days in certain geek circles. I may even be late to the game but I tried a few things over the last couple of days.

I started with one of my favorite little projects. Armstrong numbers are a form of narcissistic  number which is a number that is the sum of its own digits each raised to the power of the number of digits. I first wrote a program to calculated these as an undergraduate when I wrote programs for it in about a half dozen different languages.

I fed in the following prompt using C#, Visual Basic, and Python as the programming language.

Write a [programming language] program to calculate three digit numbers were the sum of the cube of each digit equals the original number.

The results for C# and VB were the same algorithm written in the specific syntax. The Python code was slightly different. You’ll probably not be surprised that the code ChatGPT showed me is very similar, if not identical, to code examples you can find with Google or Bing.

The C#/VB plan depends highly on integer division and the modulus operator to break down the number into its digits.

for (int I = 100; I < 1000; I++)
{
     int sum = 0;
     int temp = I;

    while (temp > 0)
     {
         int digit = temp % 10;
         sum += digit * digit * digit;
         temp /= 10;
     }

    if (sum == I)
     {
         Console.WriteLine(I);
     }
}

The Python sample changes the integer into a string and used that to address the individual digits.


for num in range(100, 1000):
   # Convert the number to a string so we can access each digit
   num_str = str(num)
   # Initialize a sum to store the sum of the cubes of the digits
   sum_of_cubes = 0
   # Iterate through each digit in the number
   for digit in num_str:
     # Convert the digit back to an integer and add the cube of it to the sum
     sum_of_cubes += int(digit) ** 3
   # If the sum of the cubes is equal to the original number, print it
   if sum_of_cubes == num:
     print(num)

Note that the Python example nicely includes comments. A dead giveaway that a student didn’t write it. All samples come with simple explanations of how the code works. The explanations tend not to be very deep so oral questioning of a student would probably still show if the student understood the code or not.

It looks like, for some simple, student exercises can be solved by ChatGPT. It is not much different from doing any other online search for the most part. How worried should teachers be about ChatGPT especially? I’m not sure. Cheating goes on all the time and there is a lot of sample code already out there for many common assignments. It’s going to be a bigger problem for educators who have very large numbers of students who can’t be familiar with the code their students write. Or who can’t ask them questions to make sure they understand what they turn in.

I think I would ask ChatGPT to solve some of my assignments before I assign them just so I know what sort of answers I might see.

Side note: Neither of the ways ChatGPT suggested is the way I solve this program. There are more than one ways to skin this cat.

Tuesday, July 12, 2022

Dice, Simulations, and Math

My friend Andrew Parsons send me this link to an interesting video The unexpected logic behind rolling multiple dice and picking the highest. Now I love simulating dice on the computer. Creating a Die class is one of my favorite projects for teaching objects and classes in programming classes. I’ve long kept example of dice with other than six sides around to help students think outside the six sided dice box. So this video grabbed my interest.

Basically the presenter is looking at what happens if you roll two dice and pick the higher value of the two. What sort of advantage does it provide?.  So this gets into some probability and some related math. One of the first things he does is to look at the problem through a simulation (His Python code is here) OK now I personally would be happy with the simulation but of course that gives one the “what happens” but doesn’t go into why it happens. The math does that. The math is presented in an interesting way if a bit fast for me. I can see it being useful in an algebra or statistics class though. Lots of good math stuff. (Can I say “math stuff?)

For a computer teacher, the things this goes though are ripe for simulation problems though. What is the result for two dice? For three dice? And what about dice with more sides than six? What do you think? Have students watch the video at home and build their own simulations to compare with the mathematical results?

BTW the dice at the top of the post were made with a laser engraver that I have been playing with. Figured dice in binary would be fun.

Tuesday, July 05, 2022

Teaching Computer Science–Moving atoms not pixels

On my first visit to the Lifelong Kindergarten Group and the MIT Media Lab, I notices a message on the windows. “Some people would rather move atoms than pixels.” That has stuck with my for years now. And it is quite true. Robots, game controllers, Internet of Things, and more are ways that computer science interacts with physical objects and not just pixels on a screen. These are ways that teachers can bring more students to more interesting (to the student) to get involved with computer science. But where to start?

Recently I posted curriculum resources that are especially good for teaching traditional computing courses. Well, cyber security is a bit new but anyway. Read that post at Welcome New Computer Science Teachers Today I want to provide some resources to bringing physical computing into the classroom.

Starting with a couple of devices that operate as “brains” for deeper involvement.

Raspberry Pi and the Micro:Bit are two of the most popular. Arduino and the Lego ev3 have been around for longer and are in wide use as well. One could get lost exploring all that LEGO Education has to offer. The Arduino Online Shop has a lot of resources as well.

Personally, I am a fan of both the Raspberry Pi and the Micro:Bit. Both the Micro:bit Educational Foundation and the Raspberry Pi Foundation have a lot of resources. Those are great places to start your exploration.

Ok, let’s talk hardware. While the sites for the Pi, Micro:Bit, Arduino, and Lego EV3 have a lot of links to resources there are more places to go depending on your interests.

Two of my favorites are AdaFruit Industries and Kitronik Ltd. They have devices that work with a lot of "brains." They have devices for all sorts of robotics or Internet of Things projects. I can spend hours looking through both getting idees for projects.

Also for the Internet of Things, I have bought a bunch of devices from Phidgets Education. I have been using these sensors and controls with Raspberry Pi in Python but Scratch, MakeCode, and Java are among other language choices. Speaking of MakeCode, that is an awesome platform for programming Micro:Bits.

I recently discovered Jacdac from Microsoft Research. Right now these devices only work with Micro:Bit but Raspberry Pi and a USB connection for laptops/desktops are projected for the future.

I could, and probably should do a post just about robots and robotics. But here are a few places to get started.

I promise a more comprehensive post of robotics soon.

Tuesday, March 08, 2022

APCS A–Java or Python?

There is a lot of discussion about moving the Advanced Placement CS A exam to Python from Java. The Collegeboard is reluctant to do so. They see APCSA as the equivalent to CS1 or the first course for CS majors in university. They cite research that indicates that APCSA students for very well in CS2 (usually data structures) and that CS2 is almost always taught in Java or C++. On the other hand, at many universities the purpose of CS 1 is growing and the audience is widening to include students from many different majors. I wrote about that yesterday (What Should APCS A Really Be About?) Mike Zamansky took it on on his blog as well (SIGCSE 2022 - What language APCS-A part 1 - the intent)

It seems like we have to first agree on the intent or purpose of APCSA (and CS1) before we discuss language. Given that agreement is never going to happen – CS people can’t agree on anything. So I will start my discussion from the standpoint of APCS A should increase diversity in computer science and prepare students for using computing in CS as well as other disciplines.

This is a concepts first decision not a language first decision. I feel that non-CS majors need the same concepts as CS majors. SO what are those concepts? Not a lot changes except that in computing widely APOs are bringing far more critical than they used to. They enable programmers to easily do things that used to be hard. They also more things we used to do early to later in a CS major.

Sorting is one example. With so many libraries to do sorting why should we spend a lot of time in a first course having students write sorts? We know they sorts they will write are not going to be up to the standards and power of sorts they can call that exist already. Algorithms? Surely there are other algorithms we can focus on to help students learn to study problems and developing algorithms?

So if we want to increase the number of students who study computer science beyond the limited scope of would be computer science majors preparing students for CS2 loses some power in the argument. And Python gains some because of all the APIs that are available and all the other disciplines that are already using it.

At SIGCSE, the panel members arguing for Python talked about much of what I write above. They also talked about Python avoiding some of the “cruft” of Java. How much easier “Hello world” is in Python for example. The “other side” focused mostly on the costs of changing and not specific criticisms of Python. There are things about Python that people do raise. It’s dynamic typing rather than Java’s strict typing. I’m a strict typing person myself but I can be open minded. Also the use of white space. Now it is not clear to me that either white space or curly braces have advantages over the other so I see that as a wash as well.

The post panel poll, FWIW, had 57% saying to switch to Python and 28% saying “keep Java” with the rest being answers all over the map.

I have no dog in this fight since I no longer teach AP CS but I am leaning toward that it is time for a change. I like the idea of a high school course, even on modeled on a university course, preparing a wider range of students for a wider range of majors.

The Collegboard is going to do what they want and the costs of changing may be as big a factor as anything. They are also driven by what universities do and as universities revisit the purpose of CS1 that will have more impact on anything anyone in high school has to say.

Mike Zamansky has a different take on this at SIGCSE 2022 - APCS-A Language strengths and weaknesses

Thursday, September 30, 2021

Define Learn To Code

I saw an interesting question today on Twitter:

My first response is that there is no definitive answer to that question. I thought about it for a while. One can learn to program by hooking a Raspberry Pi to a monitor, keyboard, and mouse and firing up Thonny and learn Python. One can use any number of online IDEs and a Chrome book. The last classes I taught had a mix of students running Eclipse and Processing on Mac and PC laptops with no appreciable difference. In short, does the computer even matter?

Maybe there is a question that has to be asked and answered before discussing the right or best laptop to use. That question is “what does it mean to “learn how to code?” I suspect we could have quite a long discussion on that question alone.

To me it boils down to:

  • What problem are you trying to solve – how do you define “learning to code”
  • What software helps you best learn to code by your definition
  • What hardware runs the software you want to run

Picking the hardware should almost always be the last thing one picks. Now I have to go think about what it means to “learn how to code.”

Monday, August 02, 2021

IoT, Python, and Raspberry Pi–Oh My

Trying learn too many things can be a risky proposition. But sometimes it feels like the way to go. Regular readers of this blog know that I have been trying to learn Python and that I have been experimenting with the Internet of Things with Phidget devices. Mixing the two is a pretty obvious step but since I really want to set up some autonomous systems without tying down my laptop, it seems like the Raspberry Pis I have accumulated would be the way to go. So mixing a new programming language (Python), with a new development domain (IoT) with a new operating system (the Raspberry Pi OS is built on Linux) seemed like something I should give a try.

Fortunately for me, the Raspberry Pi OS installation comes with the Thonny, Python IDE for beginners and the Phidgets software has downloads and installation instructions for the Pi and Thonny. I had a little trouble getting the Phidgets library to install at first but the Thonny IDE had the ability to get the library and install it for me which was a big help.

Thonny feels like a very nice IDE for beginners BTW. I am surprised I hadn’t already known about it. It installs in Windows, Mac OS, and Linux. And it is free which is also nice. Visual Studio Code also installs on Raspberry Pi so if you are using that on other platforms it could be an easy move on the Pi.

My experiment involved using the Phidget Plant Kit because water and electronics go so well together. Seriously though I like the idea of having a computer controlled watering system for plants. That’s something I have wanted to do for a while. Plus it is something that lends itself to cross curricula work in schools.

Initially I plugged in a monitor, mouse, and keyboard. Not a bad desktop if a little slower than I am used to but fine for what I am needing. Next step was connecting over the network with VNC (Virtual Network Computing). This is the step I need for setting the Pi up without tying up my monitor, keyboard, and mouse.

Well, I have some more experimenting to do. More posts when I have some projects fully completed.  I’d love to hear what other people are doing with Raspberry Pi and IoT as well as where you like to go for connectable hardware.

Tuesday, July 13, 2021

Learning My nth Programming Language

They say that the second programming language is the hardest to learn. That’s mostly because one learns how to program using their first language but each language has its own idiom.  I was lucky in that before I completed my BS degree I had learned enough of at least six programming language to write usable programs. So when at my first professional programming job they handed me a language reference manual and a functional specification and asked me to develop on a new (to me) operating system I got on fairly well.

I continued to learn new programming languages over the following years and have lost count of them all. But having a project, a good reference manual, and usually some good sample code I had a lot of fun learning.

This spring I had to reconnect with Java and learn the Processing system. To be honest I used the code students had written before I took over the class for some of how I learned Processing. Syntax is new but concepts change a lot slower and experience (in this case with XNA) was very helpful. Having a wide range of experience sure does help. And I used Bing a lot

These days I am attempting to learn Python. I have a number of Python books written for beginners. They look great for beginners but for me they just don’t work. There is to much about how to program in general and finding what I need becomes tedious. Programming language documentation has changed over the years. For the most part that’s probably good. For me, well, let’s just say I miss the old dead tree simple language reference manual.

Finding good sample programs for what I want to learn has been a struggle as well. Search engine AIs are not as good as we need them to be yet. What to do? Well, this is were community comes into play. I asked for samples on the Computer Science Educator group on Facebook. Some brief conversations and Lisa Hines, a CS teacher from Canada, shared two wonderful samples that look like they should give me a real start. The Internet sure has made for some great community building for computer science teachers.

Tuesday, May 18, 2021

Learning From My Students

Being back in the classroom has been a learning experience for me. For one thing I have had to learn a bit of Processing (the IDE) as students had been using it prior to my coming in as a replacement teacher. That’s been fun actually. And learning Processing has been on my to-do list for a while. It’s a pretty useful tool and makes graphics programming in Java almost as easy as C#/Visual Basic and the .NET library.

I have had to get reacquainted with Java as well. That’s more of a refresher than a new learning but students have given me some fresh insights into using it. One of the disadvantages of having programmed for so long is that my mindset is, to some extent, stuck in old ways of thinking. Take for loops for example. I am rather stuck in the idea that the comparisons in a for loop are just simple single Booleans when of course the Boolean expression can be a lot more complicated than that. My students are not as stuck so they suggest various options. That has been helpful in broadening my thinking.

CodingBat is a web site I have come to appreciate as well. I’ve known about it for a long time of course but never used it before because I wasn’t teaching either Java or Python. It includes a lot of very good projects that make for great homework being web based. It’s a little like Code Hunt, which sadly no longer exists. CodingBat is easier for beginners to use though which is a plus.  I found it very useful and recommend it to other teachers.

For one course I have had to review my knowledge of some data structures. Again, a refresher rather than all new learning but I think I picked up some things I either forgot or never knew. (Memory is a fickle thing)

I’ve also learned some things about teaching but that will be another post at a later date.

Wednesday, August 05, 2020

Learning Python Part 2: Distracted by a Turtle

I cracked a book and found out that Python supports turtle graphics. I love drawing pictures with graphics. I have since I was in university. So today I played around with the Python turtle a bit.

Mostly I played with a few of the usual turtle methods and wrapping drawing code inside loops. I had some fun but didn’t learn a lot. I’m not sure that was the most productive use of my time.

It did suggest that using graphics with Python is potentially a way to make learning Python more interesting. I have Mark Guzdial’s book on Media Computation around here somewhere. I’m going to dig it out and see if it the libraries for it will work in my environment.  I want to do more than draw lines.

Sunday, August 02, 2020

Learning Python: Part 1

Python has been on my radar for years but I haven’t really had the motivation to learn it myself. It’s time though for several reasons. Reason number one is that I need a learning goal to keep stretching my mind and knowledge. I don’t have a bunch of students finding new puzzles to solve so I have to make my own mistakes.

First step was to pick a development tool. I have played with a bunch. IDLE, PyCharm, Processing, and some I forget. I didn’t like any of them. So I am using Visual Studio. I expect many to tell me that was/is a horrible choice but its the devil I know so there is that. Many of the tools feel like steps backwards to me. I’ve gotten spoiled by the Intellisence in Visual Studio among other features. IDLE felt like what I used to learn BASIC-Plus 40+ years ago. Anyway, I want to spend my time learning a language not an IDE.

OF course there are two parts to learning a new programming language. Part one is the basic syntax. Part two is the idiom of the language. The first part is easy. The second not so much.

I’ve started with easy stuff. Declaration of variables, simple math, declaration of functions, and control flow. IF statements and while loops were pretty straight forward. For loops are different and idiom rears its ugly head here first for me.

For loops in Python seem to be what I think of a ForEach loops in other languages. Very powerful and useful. On the other hand, how do I do the equivalent of:

for (i=0; i <= 100; i+=5)
or
for i =0 to 100 step 5

Or do I need to use a While loop to do this? Go ahead, show off in the comments and help me out.

String manipulation, one of my favorite things to code, is probably next for me.I think that will be ok.  Lists and dictionary come after that. I think I will have to read up on them as they look to be thought of differently than arrays in the languages I am used to using. They also look like fun and powerful to use. So there is that.

Classes after that. Hopefully that moves quickly.

Once I get some basics down I’ll start looking into various libraries and what not. Perhaps go back to try some graphics in Processing. Is there an equivalent to Windows Forms like I use with C# and Visual Basic? Or do I have to go backwards again to do that?

At least I’m having fun. Now to go crack a book.