 Hello. Thank you everyone for coming to the Python coding dojo. I'm Tim Maas and I will start with a short introduction about the coding dojo in general. The dojo itself is usually the training space for martial arts, for example, in Japan. And that's the translation is the place of the way. And we are not practicing martial arts here, but instead we will be practicing coding. So in the coding dojo, we work together on solving a problem. The problems are called kathars or training sessions. And yeah, we are C five people. We will divide into different roles at this point. And the most active role in the beginning will be the driver. And that's the one person who will be coding in front. Oh, there will be no more participants. So I just started about the coding dojo and we will be everyone will be having a different world. And one of the first words will be in the driver. That's the one person sitting here in front and doing coding work on the actual test or the practice session that you want to do. It will be supplied with printing. That's a suite for my hometown just to make sure because it's always making people nervous when everyone is watching them code. So that should make it a little bit easier to do it. And the driver is in charge of the calling so he or she can do whatever they want. And of course, we are all here to support the driver. So if something is unclear, if it's unclear what to type or how to type something or how to achieve something in Python, just ask for help. And the driver also gets a person next to them. That's the navigator and both the driver navigator can also work in silence if they prefer. And yeah, the navigator, that's the second role to be having that. So we have two people pair programming in front. And the navigator is responsible to provide the print to the driver and also support the driver. However, it's necessary and of course, the driver, the navigator will be the next driver after a few minutes. So they should pay close attention about what's the way that we are going to so that they can continue in programming. And the third part is the audience. So everyone else and they should pay attention to what's happening with the driver. And whenever they are asked for help, they should respond kindly. And also if they see an opportunity to learn something or to improve something, they should wait for the right moment and then they can give a comment, ask a question whenever something is unclear. And we want to make sure that we follow this guiding principle. By a Zen teacher, that is, oh, that's a little bit of lack. So it's important to know that what Shun Ruyo Suzuki said, everything you do is right, nothing you do is wrong, yet you must still make ceaseless effort. So it's important to do. So the driver can actually do what they want, but of course it's important that they at least try to move to the goal that we have. And there's some one thing that's always wrong. That's code ridicule. So we all want, we don't want to blame anyone for doing anything here, whatever they do, regardless of their Python skills or whatever skills. It's important that we can all learn and improve here in a safe way. And the agenda for the coding dojo will be that I give another introduction and we will decide on a training session, the carter. And then we have, we will start with one driver navigator. And every five to seven minutes we switch places. So the driver becomes, can go back to the audience. The navigator becomes a new driver and someone from the audience becomes the new navigator. And we do it as long as we have time or as long as we want to do it. And probably we will, since we are not so many people, everyone will be in the driver seat several times, I guess. And now about the carters, the training sessions. So we have, so I, um, it depends on how much skills we have. So for example, with you, it's already programming Python day to day, Brandy, at least, and maybe you too. Okay. And maybe every once in a while. Okay. One, two, three. And who's never heard of Python or never programmed Python? You or what are your Python skills? Okay. So yeah, I guess then it's good to just start with a simple task. So the first two tasks are just a simple task to get to know Python. So the one thing is, oh, that's not working as expected. So the one carter, can everyone read this? Is it too small? Is this better? Okay. So one training carter would be, um, yeah, to have this problem that we have a program that gets a letter and depending on the letter, we will draw this diamond here. And for example, for the letter C, we first draw an A, then two B's, then two C's. And for example, for Z, it would be the hugest diamond. And for everything else, it would be something in the middle. And the other, uh, simple task, um, would be, uh, this bus, uh, this bus. And so the, it's easiest to see in the actual output, we will output the numbers, uh, from one to 100. And whenever the number is divisible by three, uh, we output this. And if it's divisible by five, it will be bus. And if it's divisible by both, it will be first bus, for example, for 15. So it's just a nice way to have a few, uh, a loop and then do some checks. And yeah, afterwards, we can, uh, also try, for example, a carter, um, targeted to Python, uh, to Fedora development. So, uh, yeah, I had this idea of just, for example, using, uh, the metadata API that you have in Fedora, which is just very simple web service, and then you could get, um, you, you can use it to query, uh, for package dependencies and maybe output, um, a dependency tree, or also if you have an idea for Fedora carter, we could also look into this. So is there any preference on whether we start with the diamond or fizz bus carter? So who's for the diamond carter? I count two and fizz bus, nobody. You will all have to, uh, sit in front and become a driver. So now you can decide on what you want to do. Okay. Then we'll just start with the diamond carter. And now it's time for you to get on this stage. So I need, uh, two people to come up front. One will be the driver and one, the navigator and the second one, please. Yeah, we also need the navigator. So is there someone ready for this, please? You can also get a print. Just come in. So I'm going to assume rather than reading it directly, I'm going to take that from the command line and what I remember is going for sys to get the command line. Arguments will leave the character and would be, so if I say the character I'm interested in is equal to, it was, yeah, this keyboard is going to assume that's just the first argument. No, okay. There is that. Yes. No. You have to do it like it's in the, sorry, you can either have it in the US now, then you can't look at the, uh, okay, I keep typing until I get lucky there. Yeah, okay. Maybe I should have printed it. So yeah, that's should probably be. Okay. Oh, why doesn't that spend? Oh, no, this thing seems to be German keyboard, even though. Just trying to get to that on the real world. We'd want to test the length of the back. I'm sorry. Um, oh, you're right. Zero was going to be the, um, the program name. Okay. And just to make sure I know what we're doing. I'm going to just print that out an argument. See, maybe I did not. Yep, win three. So is everyone still following what's happening here? Do we have any questions so far? Oh, it's the other tab. Okay. Yeah. So now we have the first step that you can get in character from the command line and you can also print it. So it's also always good to have small steps and see if it works. So we know where we are heading. And I believe the next thing I'm going to need is I need to turn that character into a number because I need to know what. Index I want to cast it isn't it. I'm trying to remember to get from an ASCII character to an integer. I don't know if that's just an incaster of this, uh, index of type thing we have to call on a character. Anyone idea what could be? Okay. So I think it's, um, O R D for to get the value. I think you have to use the first, they have to get the first character probably. So that's the act. So what I got was the ASCII code for C. And if I really wanted that to be the way we're doing the diamond, I probably want that to be three instead of 99. So if I subtract the lowercase a. And so actually maybe you can switch now. So you said what you would do next and then the navigator can take over and we would need a new navigator from the audience. So is anyone interested? Please. You, you, there will not, there will not be no harm done. We are all friendly here. Yeah. That's a little sad. You can also turn off the recording if it helps. So you would come up. So if you're not participating, it's not really the coding dojo. And this point. Thank you, Steve. So would you like to explain what you're doing? Yeah, I'm not trying to normalize the old, you know, by the first kind of question is whether we should tweak capital. That is characters separately from lowercase or not, or whether we should fold them into just everything be uppercase or what. It's in the web page. Using uppercase. I would or we could do it later. I guess we could do it later. If I'm lying, seven, you call fine seven. Maybe we could call lower there. You may just do 30 or something. 30 or something, something really big. Is this okay? Number two. Okay. Number two coming from zero, zero, one, two, C. Oh, lowercase. Let's control. So it's in the other tab. I'm going to import some module for, so you do want to ask a question. Maybe does anyone know the function to change any of the functions to change case for characters? Yeah, I think it's a method of a string. So if you have a string, you can do dots and upper, for example. Can you read the terminal? Or should we also increase the size? Okay. You may control plus, maybe. Is this okay? I think just dot upper there, and yet the parentheses for the function. And I think that should work. That guy also. Okay. It seems to work. So can everyone still follow what's happening here? No questions so far? Okay. So then maybe just change the words again. So is anyone up for the new navigator position, please? No problem, because you can always ask for advice when you want. And it's also just helping, for example, if you think of like the structure and then we help you to get the actual code out there. Is something that starts off indented, goes out like a diamond, and then comes back. So we type, in the example, we type in a C, and we're expecting to get this diamond shape. So, I'm, yeah, I'm pointing, and on line nine, I'm going to go ahead and type in a on line nine, we, we, well, we got the character, converted it to an uppercase letter. We subtracted the uppercase A from it. So an A is going to give us a zero, a B is going to give us a one, C would give us a two. What we're going to want to do now is a loop. I guess, I'm more Java than, I think I need to say a range here. I think if I say range, I, in range, and then a colon at the end. Now the white space magic says this is inside the for loop. And I'm just going to do a print, and that should at least give me something that counts to C. I'm going to get zero, one, two, two, zero, one. No, okay, no, I'm sorry. That, that was, I, I is two. So I counted zero, one, and it's not inclusive. If I really wanted this to go zero, one, two, I'd have to add one to it. So everyone's still following? What's going on here? You two? I do is figure out how many spaces I have to put at the beginning of the line. And let's see. If it's first, I'm going to put some extra prints and then make the prints go away. So if I say space, little two, minus, here we go, control. Okay, thank you. Now what I expect is this to count zero, one, two, three for the row, and I expect space to go, the SP to go the other way around. So it'll be counting down. I'll be doing fewer spaces each time. So I put two spaces on the first row, one on the second, and zero spaces on the third. I'm going to hide this because that was just so I knew what I was doing. I'm just going to make that print go. Yeah, I must have instead of the shift. I think you can actually do a multiply on a string to get spaces. So if I say the space times the number of spaces I want, and then I'm just going to, for right now, I'm going to put an X just to sneak up on the problem. If I save that, okay. So I got the first part of the diamond filling in. Okay, so I guess it would be a good time to switch again. Yes, of course. You can always get one. So does someone of you know there to be the navigator? Jens, maybe, again? Yeah, we will figure it out. So it's not a problem that you don't know. It's nice. Okay, but do you understand what's happening with the program, so far, or is it completely American? It's all a mystery to me. Okay, so I guess we will maybe just start going through it and then we'll see. Obviously, this is what is changing. So this is the script, I guess, and this is the output. Okay, so, but you understand the problem, what we want to solve? You want to make a diamond, right? Yeah, and so on the right hand side, you already see part of the diamond? Yeah, so I guess what I would try to do is flip that. So, well, yeah, so that the top X would be the single point, but then the other ones would go to the right. So kind of what he did, but... Yeah, okay. Okay, and so I think also the first thing is that we have Xs here instead of the actual characters. So maybe do you want to change that first, or do you want to first add the other side of the diamond? I would think it's probably best to figure out the Xs first, because you could add the letters in the end. Whatever you want to do, it's right. Fine, all right. Yeah, so this is the code that's creating the Xs. Do you have some kind of understanding what's happening there? Vaguely. I know that he's somehow identified. Yeah, maybe. This is in rows, right? Yeah, yeah, can you maybe form questions and then we try to answer them? Sure, so this base I, so I guess that refers to line nine, right? So line 13 is referring to line nine, yes? Yeah, yes, kind of. So probably we need to explain the ASCII code to you. Is someone interested in doing this? I'm not sure anyone. Sure. Yeah, line nine was saying whatever the code is for the character we just picked on the command line. If it was an A and I subtract A, I get a zero. If it was a B and I subtract A, I get a one. And that just turns it into a counter for how far into the alphabet I am. And then, so that tells me how many rows we need on the first part of the diamond. Sure. For line one, you just ignore. Okay, then at line five is actually to import some kind of system libraries. And what's the system library for? Because you look at the right side of your screen, you can actually use a command terminal. So you take in some user terminal users input. So you need to import this system library so that you can call the function from inside. So that's for line five. And for line seven, C is just an argument. What's an argument? It's just like a temporary container where equals to Cs.argv is to get an argument from your terminal from the right side, the black screen. So if you are a user, you input C, for example. So C may have an ASCII number. Maybe, for example, make it simple. Zero, one, two. So C is a third letter, right? So it's number two. So if you have print C, it can come out. Okay, then dot Apple. Apple is to change whatever the user input from lowercase to uppercase. If it's an uppercase itself, it will ignore. It will just take in at this. And then for print C, it will print out whatever the user has input. For example, this container is C. If the user inputted C into this container, it would just print out C from this container. If the user inputs A, it will print A instead of C because the user inputs A at the terminal. That's for line eight, the print C. And then for line nine, it's actually just to take out the ASCII number by using the function ORD. I don't know what is this then for. Then C zero is an argument. Then minus ORDA, because A is always the first letter out of A to Z, for example. So A is actually zero. And let's say C is two. You take two minus zero, you get two spaces. So that's why they need to find the ASCII number from the program. User input. So if user input C, you get two spaces. So for row in range i plus one, you can have the line 13. SP is actually an argument. So you get i minus row to get the row number. And then for space, you use the row number to deduct the ASCII number. You get the difference of two. Can you understand that? You are listening from a student. You calculate how many spaces you have in front of the X. So in the beginning, it's more because i goes from zero to, I know, i is always the, no, I have to check. Exactly, i is the value of how many characters we have, so how many lines more or less. So we have, that's high and row becomes higher every time we run through this loop. So this means that we're doing this several times. And the first time it will be, for example, three, two minus zero. I suppose. And that makes it two spaces here, this calculation. So for the first time, it means i is zero and row is two and row is zero. So that makes SP two and then in line 15, you have the space sign and multiply it with the value of SP. And since it's two, it outputs two spaces here and then there will be the X. And then whenever we go through this loop, SP will become smaller because row is increasing. And this means that we have only one and then zero spaces. And what we need on the other side is something that's, so for the first line, we don't need anything, but then for the second, it needs to get one and then it needs to be, yeah. So that's more or less like the calculation here, but in a way that's growing instead of, does this help you? Okay. Yeah, maybe we would just switch again and then, yeah, if it's okay. Okay, so you become the next trial and would you like to become, you explained it so well. So it's exactly the same task that you have as a navigator, just explaining or helping. They're really delicious. There will be no harm done. Thank you very much. So what would you like to do next, Jens? Well, I'd like to print the other side. And one difference I noticed is that there's two spaces here and one space, but we actually have one extra space somehow. I'm not sure why, but we have three spaces. Well, maybe it doesn't matter too much, I guess. I guess the problem is probably, I guess the spacing is not that important, I guess. As long as it looks like a diamond. So the driver navigator now are trying to figure out how many spaces we need inside the diamond. Was, I think in Python 2 you could do it, but now it's, I think, an keyword argument. So you say comma and equals an empty string and then there won't be a new line at the end. Yes, I guess we will figure that out when we cut the other things working. So on the right hand side, we now see the interactive Python console, which allows us to just test individual statements from the Python script. So do we have a question? Yeah, does anyone know how to concatenate strings in Python? With the plus sign? It needs to be some condition to only print 1x if we're at the top or bottom of the diamond, I guess, for some other clever code to do it. Maybe we should make a, I think we should make a print of some function to print a row or something. So what's your question right now? Um, I'm trying to work out how many spaces should be in the middle. How do we get that? So we start off with two spaces and then these spaces. If we had one more row, it would be, okay, let's try. You can just try out something and then see how it works and you can always make it better. Or is there some comment from the audience? Did you hear Steve? Ah, okay, yeah, two times, okay. It looks pretty nice already. Yeah, so things, you accomplished quite a lot already. So maybe it's a good time to switch again. You, you have now the chance to implement it. You can sit here and then it will, it will work out, no problem. Someone interested in becoming the navigator again? You maybe? Yeah. So can we help you? I want to store that if it's A, I want to ignore this print, else print this. So how can I get that A? Yeah, so I guess that's not the problem that we only have Xs here for now and not the actual characters. So we need the opposite of the ORD function to get the character, for example. So for example, the ORD function, it turns the character into the number. Now we need the opposite from turning the number into the character, for example, or because you wanted to get the A if I understood you correctly. Yeah, so Steve, do you know the, it's CHR. Maybe you want to try to check for a wall equals zero and then we'll see how it works. Yeah, well, we can also fix the last four later. So, yeah, so the remark was that before and in then we need a colon at the end in the line. So the statement can be used to, to only do something depending on the condition that's written down. For example, online 17, we check whether the variable row is unequal to zero and only then we'll do the print statement below. This is control. No problem. Yes, you can save it. Nice. Take your candy. So anyone up for the next navigator position. So I would say since we already have the shape of the diamond, more or less, maybe so this is the upper shape, maybe it would be a good idea to start getting the characters right. So instead of using X, use the actual character. Oh, yeah. So in line 15, we are now reversing the number code to the actual character. And we do this by using the number of the character A adding the different, the number of the wall. And then we get the character value of the character that you want to get. And I see. Oh, no, it's the also works with C and D. So what's your next plan, Katie? I'm checking. I guess the A would be the same for because it's it will be flipped. We want to check if it's the if it's a A in line 16. So if it's either the last or the first row that we're printing out, it should. Okay, that did not work. Just make a second for loop for coming the other way out of the diamond or try to concatenate a couple of lists in the range. Usually what works best is what's the symbols and then you can optimize later. So would be my hint. This is control. Yeah, I think because the range except several arguments. So it's if it's only one, it counts from zero to that number. If it has two, you can give the start value in the first value. That's not included. And if you have three arguments, the third argument says, what's the step? And then you can use, for example, minus one. You think zero would be correct there because you want to go. Yes. Ah, yes. Minus is here. So you also learn all the German layout. I think the problem is you also need to add this step. I think so at the core leads from I plus one to. Yeah, you can try it with the zero. If you move it to the right or to the left, more to the left than it will automatically. We just try. You can move it like this. So it's at least a little bit into the in the right shape. So has anyone an idea what might be wrong here? We don't need to start at I plus one because the middle row is special. So, yeah. And then it does not include row zero. So I think you have to say, I think you have to give it a minus one. No, I'm sorry. Take that one off instead of the zero. You have to say stop before minus one because it doesn't include whatever value you put there. No, we're almost done. This is kind of a season to taste thing. Yeah, everyone likes this diamond. Maybe we should also try it with other characters than D just to be sure. Yeah, I think it looks pretty nice. Yeah. Thank you, Katie. You finished the first Carter. So we can now start maybe reflect on what we did and what we learned today. If you like, do you want to say something? Just just that I learned that that German keyboard is tough. A lot of other people that I know that are programming, they don't use the German layout because all the special characters on an odd space. That's true. How did you like it? Everyone. Yeah, just like that. And all of a sudden without the prompt in front of me, I'm realizing just how little I remember a version, how much I depend on cap, please. Yeah, I see. Yeah, but also somehow the idea to keep it simple to just focus on the code because then it will also be that for some people who already know the one IDE have an advantage over the others and it's then people would start to argue which IDE to use. So it's just a simple text editor to keep it simple. Yeah, everyone like it or do you have any comments on how to improve or do it differently? Yeah, so I think from the session, we also have about 30 more minutes. So we can still do more things if you like. Just as you know, notice it's all about us doing something together so we can do whatever we want. And now everyone was brave enough to get on the stage. Think it makes it easier to do more things. So what would be your preference? Shall we also do like the other Carter, for example, the fizz bus Carter or would you like to improve this script or are you content and just want to take and do something else? Okay, so the idea was if you can just one range instead of two, I guess I think it's not a list, it's an iterator. So it's like a list, but it's technically it's a little bit different because it's like something that returns one value after the other. Yeah, that's true. So does someone want to start combining the two loops? Yeah, so one idea would be to create a function that's inside the loops instead of having the same point. So would you like to do it? You also need a navigator, of course. I have enough. Maybe could also copy this file and then we have both versions in case we break something, you could probably just save it as a different name. Or is it? Yes, Carter too, maybe. And then can you still read it? So to define a function, which is like code that you can reuse again, we use the def statement in line 10. And then afterwards, there's the name of the new function. So what's your plan here? I'm making a function basically which will do what inside the loops basically. You have to change the file name. Okay, so what we did here is just reducing the amount of code that's in the script, which is always good because then there's maintenance. The script is easy to understand what's happening here because you now see that what's happening in line 20 and 23 is exactly the same. And before that, you had to manually check with your eyes whether or not it was the same. Is it possible to have a single loop? Do you think it's better to have a single loop? There's one way to find out. There's only one way to find out, I would say. Is there any other way to combine ranges? Is it clear what's happening here, what we checked? So the idea is to combine both ranges from that you had in line 19 and 22. The problem is that the construct with range cannot be directly added, but instead you can create a list out of these ranges and then combine these lists. So you have only one range. So the question was whether or not this is the Pythonic way to do things. I think the problem here is that usually you use range and iterators or ranges because then you don't have that much of a memory impact because the list needs memory space for each element and the range only creates the elements on demand. But I guess in this way it would be okay because we know it would be at most 52 elements, so usually it's, I think you write, so one important thing is when you write code or Python code is that you write it not for the machine but also for the human who has to read it again and understand it. So that's often, should be more important than optimizing each bit out of the code length for example. I think we can also wrap up unless there's more interest in doing something. Okay, so thank you very much for coming and also thank you very much for being brave enough to get on the stage and I hope you liked the concept of it and maybe you can also do it. You find other people after flock to do it with them together. I think it's really nice format to get people from all kinds of skill levels together and I also hope you learn something even without any coding experience. And yeah, also have on the, so if you look for coding dojo you also find other resources on the internet. Presentation contains some links. So yeah, cyberdojo.org and codingdojo.org two places where you can find a lot of details about coding dojos and also code you find other simple testing tasks assignments like the ones that we did in this or the one that we did and also find my contact information in case you want to contact me about this any time later. So thank you very much and enjoy the flock.