Intro to Python ? – Part 2

You can find Part 1 here.

Intro

In this part of the series we are going to cover the very basics of Python. You may be asking: “Its Python, how hard can it get ? Its just sudo code” well that is both true and false to a degree.

Variables

Python is a dynamically typed language, however it is strongly typed. This just means that you can set a variable to any sort of data type you want without declaring it first. However it doesn’t implicitly convert types for you.

Collections

Python also contains different types array like structures. And they are all get dynamically sized of course. You have Lists and Dictionaries, they all work the way you intuitively think do, coming from another programming language. The only new sort of collection type, you will encounter is the Tuple. A Tuple is pretty much the same thing as a List however they are immutable and can not contain repeats of the same value.

Control Flow

It’s pretty basic.

Loops

Python does not find “for” loops pythonic that is way it favors “For In” loops instead. maybe asking: “What if I just want to print something 3 times ? do I have to make a list with three elements ?” The answer is no, you can use a “generator” shown in the gists below. Python also has something called “list comprehension” its very nifty to write compact and concise code.

 

You can go here to find all the relevant code, in order.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s