Sean Tibor: Hello, and welcome to teaching Python. This is episode 118. My name is Sean Tibor. I'm a coder who teaches, and my. Kelly Schuster-Paredes: Name is Kelly Schuster Perretz, and I'm a teacher who codes. Sean Tibor: And so we're switching it up a little bit. This mean a teacher who codes a lot, a lot. Kelly Schuster-Paredes: Switching it up. Sean Tibor: Yeah. We're going to try something a little bit different. This is going to be a short episode, a quick stream. Hopefully we'll have a few people join us. But honestly, we're just going to try to pop through a quick topic and make it a regular thing. So every Wednesday night our time, we're going to put together a brief bite sized tip for our listeners that helps them teach or learn a little bit better. So we'll see how this goes. There's no wins of the week. There's no witty banter between us. We're just going to jump right into talking about teaching and talking about a one bite sized topic. Kelly Schuster-Paredes: This is a good challenge for you. Sean Tibor: We'll see how it goes. Let me see if I can present. Oh, I can't present unless I share the entire screen. And I have a very big screen going right now. Let's just try this. And Kelly, I'm going to find another way to share screens later. But basically what I wanted to talk today about was automated testing. I've been doing a lot of this at work. I've been doing writing a lot of tests, and I realized how valuable this is for teachers to be able to grade things faster and see if students really got the point of the assignment. But it also occurred to me that this is really valuable for the learners themselves because they can see if they got it right and they can iterate and go through that loop of learning really fast because they can try something, check to see if it works, try something, check to see if it works. And it should make it a lot easier than guessing that you got it right and sending it into the teacher only to find out a week or two later whether it actually works. Kelly Schuster-Paredes: Yeah. And doesn't it help you understand your code better and helps you catch coding errors a little bit faster as well? Sean Tibor: Sure. For a professional software developer, they're great. : Right. Sean Tibor: So when you're writing code for production use or something, you have to make sure is right. Tests are a really important part of that development process because you can verify that everything is working the way it's supposed to. And when you change your code, if it fails, some of the tests that you've written, you know exactly where to go look and what to test. So it's useful on the coding side, but it's also really valuable on the teaching side. Kelly Schuster-Paredes: Very cool. Okay, show us. Sean Tibor: Okay, so I'm going to try to use my words to paint a picture here. Unknown: Okay. Sean Tibor: Kelly, you have described yourself as being really good at teaching the basics, right, of Python so you are an expert at the basics, which I love. Let's take something really simple. Let's say you're teaching F strings to students, right? And so you want to teach them how to use F strings. And so how would you normally set that up? Like, if you ask them to code something to prove that they know how to use F strings, how would you do that? Kelly Schuster-Paredes: I will do like, a series of challenges or something, and I would say make a variable and ask for some input and reproduce a response that makes sense using an F string. Do you want more? Sean Tibor: No, that's like maybe you have a variable like Best Teacher in the World and it's set to paretus, right? Kelly Schuster-Paredes: Correct. Sean Tibor: Then you have an F string that you want to say kelly Paretus or teacher. Best Teacher in the World is the best teacher in the world. Unknown: Right. Sean Tibor: So it's an F string. You have your little best teacher in the world variable in those curly braces, and then you have the rest of the string, which is the best teacher in the world. Unknown: Right? Sean Tibor: Now, if you're looking at that manually, what you're doing as the teacher to assess whether they got it is you're looking to see, did they use the variable? Did they write the sentence out? Did they use enough string to do that? Unknown: Right. Sean Tibor: And does it output the proper sentence at the end with the variable that you chose? Okay. So in Replit for education, they have this feature. They call it input output testing. Unknown: Right. Sean Tibor: So if I have input going in, I'm going to test the output and see if it matches what I expect. Unknown: Right? Sean Tibor: So when you're talking about automated testing, it's really what is the expected value or what is the expected output? So if they're running this code, you expect to see it print, kelly Paretus is the best teacher in the world, right? So what you do is you create a test for that and say, is the output of this program when you run it, Kelly Paretus is the best teacher in the world. You check to see if the output of the program matches an expected string that you've already created. If it does, then the test passes, right? If it doesn't match, not only can you say, hey, that failed, but you can tell them exactly what failed. Like, it's supposed to say, Kelly Paretus is the best teacher in the world, but what you wrote was, Kelly Paretus is awful, and I don't want to learn from her ever again. Unknown: Right. Kelly Schuster-Paredes: They failed. Sean Tibor: Or maybe they put an exclamation point on it when all you wanted was a period, right. So you can check individual characters to make sure that it matches correctly, right. It'll show you the difference. So when you write this as a test and you can write this in replet with their input output testing. You create a little instruction at the end and it's just a match, right. I have it here on my screen and the test is here's, the test name, it's string formatting. It has an input box so you can put your standard in, and it has an expected output where you can type the string that you want. Unknown: Right. Sean Tibor: And then you choose the type of test that it's going to be. And so this is a match test. We want to make sure that it matches the value that it's expected. Kelly Schuster-Paredes: And that would be good in the case, for example, if we were doing the password and username kind of example, you want it to match exactly because it's very important to have the username and the password. And that's something that a lot of people can relate to because that's in everything you right. Sean Tibor: Right. So you could have this test of maybe I have the input of Kelly Paretus and then the output could be kelly Paratus is the best teacher in the world. Unknown: Right. Sean Tibor: So you could use the input variables and seed it with the input that you want and then check to see if their program produces the correct output. And we'll come back to that in a minute. It's kind of an important idea. So what this allows the student to do in Replit and in other programs that implement this is that when they go to create the assignment or complete the assignment, they run their program and it tells them right there at that moment, your test passed or your test failed. Unknown: Right. Sean Tibor: They know right then whether they need to fix it or not. Unknown: Right. Sean Tibor: And then when you, as the teacher, come back and look at this, you can see all of your assignments, all of these assignments passed and all of these other assignments did not pass and why, right? So you can see their code, you can see what the test was. But the other thing that I like about this from a teaching perspective is it causes you as the teacher to think, what do I really expect them to be able to do? What's the outcome of this experience? Unknown: Right? Sean Tibor: In this case, it's like I want them to be able to use F strings. I want them to know how it's going to work. Right, so you are thinking more about the outcome of the exercise and less about the rote repetition of just practice 15 different F strings. You're really thinking about what do I, Kelly, want them to be able to do and perform at the completion of this assignment? Kelly Schuster-Paredes: And that's huge. That's like your standards, right? So I want them to complete conditional statements. I want them to build a function. I want them to do X, Y, and Z. I don't really care maybe about that content or whatever they put in with the sentence. I'm just checking for that concept completion data. Sean Tibor: Right. So this Pytest in replet is really great because it's input output. It's the standard input and it's the standard output. So you can use it for those early basics, right, where maybe you haven't taught them about functions yet. You just want them to write some step by step actions right now. There was a point when we were teaching where you were sitting there in class one day and I was teaching functions, and you're like, I get it, I finally get it, I understand. Right? Once they have that moment, or once you get them there with functions, then what you can do, it's kind of like a level up in your ability to teach this. What you can do then is create unit tests. And so a unit test is being able to provide inputs to a function and verify that the outputs of that function match what you expect, right? And this is specifically in Replit, there's some more sophisticated things you can do when you're doing software development. But in Replit, this lets you see did they call this? You can call their function and see if it matches the output that you expected, right? Kelly Schuster-Paredes: Sorry, is that an output with the print and or return whatever output it is? Sean Tibor: So ideally you want to do it with the return value. So you're providing the parameters for the function to exercise it, and then you're returning a value and checking to see that that return value matches what you expect. Kelly Schuster-Paredes: Which is really nice because then they can see that that's one of the hard parts with functions, right? Because they can't really get the concept that it's a stored value or returned value and you would have to reassign it in order to get it, et cetera, et cetera. And that's quite helpful, right? Sean Tibor: And so it brings me to one more concept. And this is like, I think, the real bite sized tip here, right? You and I have seen this before, where students, in order to pass the test, will hard code a value, right? So instead of saying using an F string, they'll just write the string that needs to be output and they'll submit it, right? So when you're doing this, write more than one test. Write multiple tests, like with different inputs, and make sure that the different inputs match the expected output, right? At least if they're going to hard code some values in there, make them work for it, like put in an if else statement, right? And I'm sure a lot of the people that are familiar with tests know that you can create synthetic inputs and know what the output will be. So you can generate your own input and calculate what the output should be and then check that it does that. But for this, keep it simple. Do two or three different inputs that they have to handle and the corresponding outputs to verify that they're not just hard coding the string in there to output it or to return it back from their function. Kelly Schuster-Paredes: Very good. And you still have three more minutes. What else to share? Sean Tibor: The great thing about this is that you also start to get students thinking about what is the purpose of my code, right? It's not necessarily to do whatever I want, but it's to serve a specific purpose. Unknown: Right. Sean Tibor: So my code is not just a bunch of spaghetti mess that sort of works. It's organized, it's logical, it's something that's easily tested. Unknown: Right. Sean Tibor: That's the other thing that you want to consider as a teacher here, is what are you really assessing? Unknown: Right? Sean Tibor: What do you want them to practice? What are you having them demonstrate in terms of their knowledge? So make sure that when you're designing these exercises and you're designing the tests that go with them, that they make sense from a learning pedagogical or androgogical output perspective, like, what is the desired outcome? It's not the ability to pass the tests, it's to learn something, to demonstrate the knowledge and the application of that knowledge in a coding environment. If all it was, was just to pass the test, we could probably teach Chat GBT to do that. So try to think about tests that are purposeful, right, that they're relevant and that they cause students to think a little bit about what the true code that they have to write will be. So it's not just something they can put into Chat GPT and say, hey, write me the code for this and I'm off and running. Unknown: Right. Sean Tibor: They probably can still do that, but at least this way they have to think about how to articulate that to Chat GBT to get the right output as code. Kelly Schuster-Paredes: And that's half the battle. Correct? Being able to articulate it, being able to explain it, being able to read what you're writing and know what you want out. If you can get the students at least that far, regardless if they use Chat GPT, at least they're communicating some knowledge in that topic. Sean Tibor: Exactly. So there's my little bite. Write some tests, use some tests. I know that, for example, Replit has built in automated testing, right? The code challenges from the Pybytes group has built in testing with it, you can even write your own. And there are other testing frameworks where you could take program files from the student and run it through your test battery. So it's not something that's specific to any given platform. And also, it will probably cause you to write better code yourself. Kelly Schuster-Paredes: Yeah. And that's half the fun, is getting to be a better coder so that you can become a better teacher. Sean Tibor: Exactly. Kelly Schuster-Paredes: Well done. 14 minutes. We did it. Sean Tibor: Look at that. Kelly Schuster-Paredes: High five. Sean Tibor: Here's our Wednesday teaching tip. So I think what we're going to try to do, and we'll see how this goes, is that I'm going to try to come up with the coding tip of the week, and Kelly's going to try to come up with the teaching tip of the week, and we'll try to make sure that it's crossover relevant for everybody. So see how it goes? Kelly Schuster-Paredes: See how it goes. You're going to sign off? Sean Tibor: I think we're here. I mean, this is it. So for teaching python, this is Sean. Kelly Schuster-Paredes: And this is Kelly signing off.