La Boina Roja

Linux, the struggles are real!


Leave a comment

How to make typing along with Python tutorials easier.

A lot of youtube vids use IDLE in their tutorial, there is absolutely nothing wrong with that. In matter of fact, it makes typing along easier if you use IDLE too, but situations like in the picture below piss me off photo piangry.gif!

typealong1

I prefer this  photo shiny.gif it saves me the hassle of changing screens.

typealong2

So what happened in the second picture? Well, I used Python’s built in interpreter which you can open by simply typing python in the terminal. Look:

typingalong3

And I made the terminal’s background color transparent by changing it’s transparency. You do this by

Edit > Preferences

typingalong4

The following screen will appear, select the tab Appearance, in this tab you can change the transparency settings.

typingalong5

If you are finished with the interpreter but have other stuff to do in terminal, all you have to do is press CTRL d and the interpreter will close and you can do whatever you need to do in terminal.

typingalong6

(Yes, another se7en  photo heart.gif!)

(Remember, you can always do the cliccie for larger piccie photo puh2.gif)


Leave a comment

Recommendation: The Art and Craft of Programming: Python Edition

Free e book written by John C. Lutsh available in HTML and PDF format, this book will not teach you to program. You will learn about how and why things work the way they do in Python on a basic level.

This is a well written starters guide, the PDF file is about 138 pages long. The writer is very novice friendly he, bothers to explain what precedence is for example. He does this in very a efficient and effective way, I personally liked how he explained assignments

cliccie for larger piccie

I myself will not go through the entire book from beginning to end, but seeing how he explains basic things rather well, I will use this book as a reference guide. That is another beauty of this book, it is written so well you only can go through the for you  relevant chapters. Without worrying whether you should have read the chapters before it or not. He should add a search function on the HTML version of the book though null

He has some small exercises in the book, with (thank God null) the answers.

The book is about Python 3, but since the writer is teaching you about concepts in Python,  you can use this book for Python 2 too.


Leave a comment

Recommendation: Hacking Secret Ciphers with Python

Want to learn Python and learn how to hack at the same time ?

Then this book is for you photo thumbsup.gif
cover_hackingciphers_thumb

This is a beginner book in Python 3, while learning this you also learn hacking. Cryptography is a subject touched in this book, now I know that a lot of cryptography courses require a decent understanding of math.  But When I asked Al Sweigart about this, he came with this reply:

You only need to know basic arithmetic. The book covers the mod operator, greatest-common-divisor, and everything else math-related. There really isn’t that much to it.

So basically, any 10 year old would be able to follow along.

I most likely will not be doing this course null  I am recommending this book because during my initial searches about Python beginner courses, his earlier books came highly recommended by several communities. The other reason why I recommend him is, he is willing to answer questions from people who are going through the books and he is honest null Another quote:

Basically, this book uses crypto as a way to make learning programming interesting. It’s good for a complete beginner, but not comprehensive for becoming a programmer.

Now, if only other people were as honest about their beginner courses null

Ooh, did I mention you can get this book for free null You can get this book in various formats too!( HTML, PDF and mobi).

When you finished the book, you should check out Mystery Twister C3 it is a platform, created by Al Sweigart, where you can test your cipher skills and discuss your methods.  The last part is very important if you want to become a (better) programmer, imho.


2 Comments

Coursera starts a Python course on the 15th of April!

The course is called “An Introduction to Interactive Programming in Python”   and it’s free  photo thumbsup.gif  The course will cover Python 2.

Coursera is unfortunately one of those institutions that hasn’t implemented signing in by Google, Facebook etc. yet. But from what I’ve heard and read they give awesome classes. So it I think it is worth going through another sign up process again.

Since you’ve asked  photo piwink.gif no, I will not be joining that class.


Leave a comment

Slicing in Python

sword

Ha! Another trickety trick that is used on Python newbies is slicing. The trick is in getting the correct characters(in case of a string) or the correct items(in case of a list). They often make your mind boggle  photo piangry.gif by asking you first to use len() to check the length of a list(or string).

Let’s say you have this list:

the_list = [“Master Chief”, “James”, “Miranda Keys”, “Cortana”, “343 Guilty Spark”, “Deja”]

As you know, that even though there are 6 items in the list but Python will only index 5 items. That’s because Python starts indexing from 0. Don’t be fooled by len(), however!

lenismean

As you can see len() returned 6, this is what makes slicing so tricky!

Always remember:

“Python counts from 1, but indexes from 0.”

And of course there is another thing to keep in mind( you really didn’t think it would be that easy right  photo emo.gif ), in case of slicing Python will always returns the before last index.

So if you would like to get a slice containing only the first two items, you should type this:

first_two = the_list[:2]

Why didn’t I type the 0? When your slice needs to have the first item in it there is no need to type the 0, you can do it though if you want.

Check the following screen shot where I’m attempting  photo piwink.gif to slice the first  two items (“Master Chief”, “James”).

first_two

Now, you know Python always returns the before last index. The next question will be to include the last item in your slice. Now what  photo redface.gif

You get the last item by typing the index of the first item you want and leave the space after the colon blank.(In this specific case we are talking about the 5th index, which happens to be the 6th item.) It looks like this:

ai = the_list[3:]

listai

Remember slicing does not affect the original list! originallist

(You can always do the cliccy for a larger piccie!)


1 Comment

Get even with Modulo!

DOKONUS 2c657

If you just started learning Python, one off the things people like to trick you with, is asking you to create a function with a code that should do something if it’s outcome is even. They expect you’ll mess around with stuff like “int”, type() etc.

But don’t be afraid  photo smile.gif it is very easy to create such a piece of code. Let’s say the parameter of your function is x and the code should evaluate (=check) if x is even. This is how you do it:

x % 2 == 0

See the % is called the Modulo, and when used as an arithmetic operator it returns the remainder of an integer division.

9 % 2 will return the remainder 1, 2 goes into 9 evenly 4 times.

12 % 4 there is no remainder, 4 goes into 12 evenly 3 times.

And as you know, no remainder equals to 0.

And of course if the outcome should be uneven you would use this:

x % 2 != 0


1 Comment

Free online Python 2 courses!

As you know I am struggling to learn Python 2. In case you wonder why Python 2 and not Python 3? For me it was just a matter of convenience really, I couldn’t point out the differences between those 2 even if it could save my life Photobucket I started with “Learn Python the Hard Way” and it suggested to install Python 2, as you know I ru(i)n Linux on my Desktop and it had Python 2 pre- installed, so that was easy.

  1. Learn Python the Hard Way
  2. Code Academy
  3. Udacity , (CS101 Introduction to Computer Science)
  4. LearnPython.org
  5. The Python Tutorial (official tutorial by http://www.python.org)

 

“Learn Python the Hard Way” and the  require no registration Photobucket for the others you can use your Google account to log in. As you know I’m doing the first two courses right now and yes I am planning to the last 2 too! I like to listen to Sal Khan his voice and when you finish the course at Udacity, you’ll get a certificate with a picture of a robot on it Photobucket!

I would like to point out that “Learn Python the Hard Way” doesn’t seem to require much mathematical insight as far as I can see (I am at exercise 25 at the moment of writing), if you can think logical you’re fixed Photobucket The Code Academy’ s Python course is a different story though, this is a screen shot of 1 of their exercises:

cliccie for larger piccie

Photobucket

If your math is a bit rusty or you aren’t the most gifted mathematician around,  it might help to look at Khan Academy’s math curriculum.