 In order to lead into what we are going to do next, this is what I want you to do. We will write a function which will take one number as the argument and return true or false depending on whether the given number is Armstrong and the Armstrong number is defined as a 3 digit number rather a 3 digit Armstrong number is defined as number that is equal to the sum of the cube of its digits. One example is given, agreed? So, create a directory called Armstrong, start repository in there and put down the code for whatever you want to do in that. Put down your first version because like I said for the rest of the I am not going to sorry before we start I am not talking about using push and pull much clone and all that because they are primarily useful for working on multiple people working on a central repository. The reason for us to include version control is definitely includes that because if any of your students or you contribute to open source project you will see that what we will do is maybe little later before the break we will show you a mercurial repository and say how to get it clone it. So, that you understand how to use those commands, but we expect 95 percent of the time you as well as the students you teach will be only using it for personal work and I strongly urge you to start doing it. Do not treat this as two different things, do not do that thought thought thought and wrote wrong mistake mercurial is something that should become a tool you use day in and day out as part of your job. So, before the break we will show you how the distributed computing aspect or the distributed version control and collaborative aspects of mercurial are. We do not expect you to be using them. So, we do not want to make a big song and dance about it. Now we just want to show you it is there and that is one of its primary strengths alright. So, having said that let us now you created repository and start putting down the first set of code you want and I suggest you commit different versions at what you think are useful check points. For example, one useful check point may be open a file called Armstrong dot pi simply in the comment right this is what the program is expected to do this is the assignment and commit it immediately. So, the commit statement can be captured problem statement then the first version and so on then we will talk about once you have done that and you have committed one or two we will talk about certain other things. For example, if you achieve all I want to achieve using this example at the end of this discussion you would A be comfortable using the version control B you will also understand how to write code for a certain class of problems how to go about writing code for a certain class of problems alright and we will lead on to the test driven development from there. So, you also start thinking about if this is the code I am writing how do I test it in other words how do I ensure it is working properly I suggest you also spend time thinking about that. Let me repeat create a repository call it Armstrong or whatever you want and make a couple of commits meaningful commits you need only one file multiple file choices yours, but include test code. So, that you know it you can show that it works if you apply your mind for Armstrong numbers it is very unlikely you require sci pi or pi lab or any of the complicated technology. So, like writing om before you start anything do not write import sci lab sci-fi and all that out of habit. Please note I said you have to write a function which must check whether the number given is Armstrong or not and one of my favorite maxims is naming is 80 percent of programming I walked around I see om as names which makes me feel rather sad from the name do I know what type of data it returns do you know if the name is om or om if thought a little and named it is Armstrong automatically anyone reading the code will know this returns a boolean it is these simple steps which ensure your code is of a much higher quality think before you give a name to a function or a variable do not type the character nearest your left hand one more important style guideline a function should never print do not ever have a function each Armstrong that from inside prints a and all that it should return true or false that is all function should just return a value function should never do printing or any such thing a couple of observations coding style observations second did you discuss basic pp8 any time without mentioning it at least no couple of coding conventions which are very strongly held in the python community I see many people writing a equal to without a space before the operator it is a bad idea there must be a space before and after every operator basic thing and choose good names then another stylistic thing which I not specific to python but which I see in a large number of cases is people write code something like this I am using python syntax but this works in many other languages too you can read this right the code on this board is readable right a very bad style can anybody tell me why python has true boolean 0 1 or not boolean alpha beta do not exist I use alpha and beta so that you do not comment on them if I use the x y you will say x y are bad names I thought I will write alpha beta so that you will not focus on the names oh boy I am a bad teacher no no we wanted to return a boolean value so you should never be returning text yeah we could avoid the else yes but I am saying this whole style is wrong very bad that is worse if anything can be worse than this difficult imagine that will be it is not because it is one line it tells you exactly what is happening please remember understand I am not saying this is better because it reduces number of lines no you are returning a boolean expression boolean expressions have only one value sorry true or false values which is what you want so never write code which does that if something returned true otherwise return false is a very very bad coding style people anybody still stuck with the program accepted answers are yes or no silence is not done this all right let us let me try and may I have your attention please so there are two ways of doing this one is to say take the last digit you can do it this way let me do it directly so three variables u t and h rather than a b c units 10s 100s even thing them units 10s h u n s may be be even better now this is a reasonably bad version you get two out of ten it was only for three digits it is not a very nice thing that way but if you want to expand it to other 4 digit Tom's wrong number this is not going to be easily expandable are there 4 digit Tom's wrong numbers yes an n digit Tom's wrong number is a number that is equal to the nth power of its digits 4 digit Tom's wrong number is a 4 digit number a b c d such that it is a power 4 plus 3 power 4 plus 3 power 4 plus d power 4 so if you want to write that sort of code this is off it is not easy to expand which brings us to the next rule we gave one rule naming is 80 percent the other rule is there must be one only one and only one obvious place to make any change if there is a change in spec if you are going to edit your code in two places to implement that change your original program is badly written so if I move from third to fourth power there are two things wrong with it the first three I have to add I have to edit all the three lines all the four lines here correct may be you need not be edited that is about it the first line may survive I have to edit all other lines so that itself tells me it is not well structured all right what is the other method some people have used this method that is store the number x in some value n and then create some another variable 0 yes initialize it to 0 while x is greater than 0 obviously the n s to be improved the name is bad but even if you improve it what is the advantage if I want to do for power 4 I have to make only one change correct obviously this is a much better one but still in my dictionary this will get 4 out of 10 not more in order to cross that 8 or 9 out of 10 for this problem what is there only four and a half lines of code in that what more improvement is there well we are not in the domain of python anymore if you discuss that we are discussing how to write good code which is important I hope some of you will take the idea and pass it on your students