Tuesday, 9 September 2014

Back to Python!

Good evening minions!

Yes there is another post this evening, this is because i am also supposed to be mastering the art of Python and i can't get any better if i don't do any. As you will gather by now, if i'm learning then i'm also sharing the knowledge with you guys.

So, my last post regarding python essentially told you that i'm trying to teach myself offline because it's all fun and games on Code Academy until you need to actually remember the coding and if your anything like me, you've got a memory like a sieve so you won't remember CA's instructions.

I come to you live from my python lesson, like i said last time, im using Geany on Kali linux. See below















As you can see, i've somewhat jumped into the lesson but the program on the left is geany and on the right is a linux terminal (like command line from Windows).

In the above box, i have been testing the concept of adding onto a preassigned variable at the print stage, so in the code above, i'm telling python that the prefix is Py and in the print stage telling Python to add the word "thon" to the end of the variable, making the word Python. (You don't have to use the +, i just do it for my own mental workings).

The next mini lesson for the basics we're walking through atm is typing a sentence on multiple lines on Geany but it appearing as one sentence in Python. Watch and learn minions :)

The way we do this is that we begin like normal, text =, but this is where we change, because now we add in brackets so it becomes;
text = ('this sentence is going to go over 2 lines'
'but as long as we use the brackets and apostrophes, it'll be one sentence')
So you use the apostrophes like normal to show python that there is text you want to add but there are brackets at the start and finish. See below















We'll move onto a fresh post now because this is a little long..

**EDIT - This post is not to say that any one Python terminal is better than the other, its all about preference but if you want one that works on Windows with colours, Sublime Text owns it.

No comments:

Post a Comment