Python

Python (currently version 3) is a dynamically typed programming language with both imperative and functional features. Python source code is executed by the Python interpreter which internally compiles the code to bytecode for better performance.

Why would I learn this language?

Python has a very clean syntax and a well thought out design.

It is used in many different areas of software engineering such as web programming, scientific and numerical computing, and comes with a large standard library. There are many third party libraries available too.

Python is used by many large organizations in many successful projects.

Starting Points

Beginner's Guide to Python
Learn to program using Python. A beginners guide which includes to links to many useful resources.
Learning to Program with Python (version 2)
Learn to make a game of hangman from scratch.

Example Code

The following is an example of the Fizz Buzz problem. You can run and edit this program here.

for i in range(1, 101):
    if i % 3 == 0 and i % 5 == 0:
        print("FizzBuzz")
    elif i % 3 == 0:
        print("Fizz")
    elif i % 5 == 0:
        print("Buzz")
    else:
        print(i)

The following is an example of the 100 doors problem. You can run and edit this progam here.

def doors (n):
	# Initialize an array
	doors = [False] * n
	
	# Process the doors
	for i in range(n):
		for j in range(i, n, i+1):
			doors[j] = not doors[j]
	
	# Print out the results
	for k, door in enumerate(doors):
		print("Door %d is" % (k+1), 'open.' if door else 'closed.')

# Call the function doors with n = 100
doors(100)

Further Reading

comments powered by Disqus