Save this video free

Python (Fall 2026) Module 7-6: Fun With Colors

Bill Moseley, Ph.D. - Computer Science Educator · 8:06 · Watch on YouTube

Python (Fall 2026) Module 7-6: Fun With Colors Watch on YouTube →

Overview

Bill Moseley shows how Python command-line output can use ANSI escape sequences to display colored text and backgrounds, with color settings remaining active until changed or reset. He demonstrates wrapping these codes in parameterized helper functions such as `printRed` and `printYellow`, making color output reusable and useful for communicating warnings or unavailable options to users.

Key takeaways

Chapters

0:00 ANSI Escape Sequences Add Color to Python Terminal Output
4:13 Reusable `printRed` and `printYellow` Helper Functions
7:05 Use Color to Communicate and Explore ANSI Options

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:03 All right, welcome back everybody. We're going  to get into custom functions part two. Today we're going to dig a little deeper into some extra  tricks that you can do with custom functions, and then I'm going to go over the assignment for this  module, and then you'll have some work time as well. But first, I'm going to introduce something  that is mostly just for fun. It's not going to be required of you in any of the assignments in  this class, but I am a big fan of trying to make learning new things fun. So, I thought I would  share this little trick with you. And you know, so far all of our stuff that we've done has  looked like this. Just boring, same color.

1:01 And that's kind of the limit. But if you go to  module 7 in Canvas under links and tools here, you'll find a link to this page here. It's  called ANSI escape sequences for color in Python. So, I, we're not at the point where we're making  a graphical user interface yet with buttons and things like that, but if you read through  this, you will see that there are special codes that you can slip into your text when you  print things out that will allow you to print things in different colors. So, for example, if  I want to change this text to something else, I can type a code in here

1:54 that will change that text to red. I can also change the  background color of the text to different colors. So using these little codes here,  and this just looks like some gibberish, right? So if I separate this out  so you can see one from the other. Basically, this first string here is the  code that says change the background of

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Bill Moseley, Ph.D. - Computer Science Educator.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.