Author Archives: Joel Erles


Basic types and their use in Python

  • Numbers

Number data types store numeric values. Number objects are created when you assign a value to them. For example:

var1 = 1

var2 = 10

var3 = var1 + var2


Run code -> 11

  • String

Strings in Python are identified as a contiguous set of characters represented in the quotation marks.

str = ‘Hello World!’


Run code-> Hello World!

  • List

Lists are the most versatile of Python’s compound data types. A list contains items separated by commas and enclosed within square brackets ([]). The values stored in a list can be accessed using the slice operator ([ ] and [:]) with indexes starting at 0 in the beginning of the list and working their way to end -1.

list = [ ‘abcd’, 786 , 2.23, ‘john’, 70.2 ]



Run code:

[‘abcd’, 786, 2.23, ‘john’, 70.200000000000003]


  • Tuple

A tuple consists of a number of values separated by commas. The main differences between lists and tuples are: Lists are enclosed in brackets ( [ ] ) and their elements and size can be changed, while tuples are enclosed in parentheses ( ( ) ) and cannot be updated. Tuples can be thought of as read-only lists.

tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )



Run code:

(‘abcd’, 786, 2.23, ‘john’, 70.200000000000003)


  • Dictionary

They work like associative arrays or hashes found in Perl and consist of key-value pairs. Dictionaries are enclosed by curly braces ({ }) and values can be assigned and accessed using square braces ([]).

dict = {}

dict[‘one’] = “This is one”

dict[2] = “This is two”

print dict[‘one’]

print dict[2]

Run code:

This is one

This is two


1014 09


Python conventions (Zen of Python)

The philosophy of Python is summarized by the document “PEP 20 (The Zen of Python)”

The Zen of Python

Beautiful is better than ugly.

Explicit is better than implicit.

Simple is better than complex.

Complex is better than complicated.

Flat is better than nested.

Sparse is better than dense.

Readability counts.

Special cases aren’t special enough to break the rules.

Although practicality beats purity.

Errors should never pass silently.

Unless explicitly silenced.

In the face of ambiguity, refuse the temptation to guess.

There should be one– and preferably only one –obvious way to do it.

Although that way may not be obvious at first unless you’re Dutch.

Now is better than never.

Although never is often better than *right* now.

If the implementation is hard to explain, it’s a bad idea.

If the implementation is easy to explain, it may be a good idea.

Namespaces are one honking great idea — let’s do more of those!


08 1014



Submit work via Blog RSS and GitHub

To submit your work via Blog RSS you will need to tag a post so the information can be gathered by the system (in this case we use “#”). Example: This will allow the system to gather all the posts that are tagged like that and to take them to a single page so the users can see what other users say about a specific topic.

And to submit it via GitHub you will need to create an account: Join GitHub

Once you have your account you will need to download the GitHub app:

                                                           Mac       Windows

Now, I’ll share with you this AWESOME VIDEO so you can learn how to use the app to upload your codes from your computer to the web.

04 1014

Quiz #11 – Gone Bananas for Files

Quiz #10 – Wish Lists

Bonus Quiz – ECOS

Quiz #9 – Failing is not an Option

WSQ15 – Final Dash

So, four weeks left… this is my schedule.

Week 1: Weekly WSQ, Quizz and 6 Masteries.

Week 2: Weekly WSQ, Quizz and 6 Masteries.

Week 3: Weekly WSQ, Quizz and 6 Masteries.

Week 4: Weekly WSQ, Quizz and 4 Masteries.

WSQ14 – Estimating e

WSQ13 – Babylonian Method