Vous êtes sur la page 1sur 1

EXECUTING A SEQUENCE OF INSTRUCTIONS IN THE

CONSOLE

So we saw what is print command and let us do something, let us use it properly. When I say
a equals one and then print a, you get one. When I say a equals a plus one it means you are
incrementing a by one so what will happen to a? It will become two. I again say ‘a’ equals ‘a
plus one’ and then I say ‘a’ becomes three, ‘a’ equals ‘a plus one’ and then ‘a’ equals to four
and so on correct? You now follow what is print command very well ok, so now I can
actually say ‘a’ equals ‘a plus’ one and then put a colon and then say print of a these two
commands gets executed simultaneously firstly it will as good as executing the command and
then executing this command so if I type the same thing and plus enter it will display six,
seven, eight, nine, ten, eleven, twelve and so on ok, let me clear the screen by typing clear on
now a equals one once again print a which will make it print one, now look at this a equals a
plus one print ‘a’ again, I put a colon ok, another this is semi colon not colon sorry and then I
say ‘a’ equals ‘a plus one’ once again and I put a semi colon and say print ‘a’ once again,
again a semi colon ‘a’ equals ‘a plus one’ then I say print ‘a’ what is this do? It will simply
executes all these commands in a sequence enter, two three four why because ‘a’ was already
one I incremented it by one it became two and then it printed ‘a’ and so on ok? So what I
should do is I should probably print a, a equals one assign that and then print a and then put a
semi colon and then increment a and so on now this is a sequence of instructions do you
understand that, a equals one is the first thing assign a to one in plain English this what
happening, assign ‘a’ assign one to a not a to one I am sorry don’t assign ‘a’ to one assign,
you assign one to ‘a’ and then you print what is in a and then again you make a become one
more that’s what this means, sir why does we write it as a equal a plus one that’s the
convention, you must learn it that way, this is how you can talk to python ok? ‘a’ equals ‘a
plus one’ incremented, print ‘a’ now, now ‘a’ will be displayed as two, ‘a’ equals ‘a plus one’
now ‘a’ becomes three now, ‘a’ will be printed as three, a equals ‘a plus one’, ‘a’ becomes
four then ‘a’ will be printed as four, perfect let’s execute this and see this is what it happens, it
displays hip hip hurray! We are done. It says one, two, three, and four you have learnt one of
the important aspects of python, important aspects of programming in general, and
programming is all about executing a sequence of instructions to the computer. Telling the
computer what to do right? Ok. Perfect. So now you understand how to use print command,
what are variables, and how you can type something in a sequence?

Vous aimerez peut-être aussi